Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Ultimate Member and Ajax Search Pro › Reply To: Ultimate Member and Ajax Search Pro
Hi,
The plugin search query is separate from the default wordpress search, UM plugin probably adds some sort of an exclusion by ID or something similar to the query.
Unfortunately I could not find anything about this in their API, so I’m not sure how to do it, but it definitely requires a custom code. If they have a hook to the current_user_can function, then this code may do the trick:
Try adding this custom code to the functions.php in your theme/child theme directory. Before editing, please make sure to have a full site back-up just in case!
add_filter( 'asp_results', 'asp_filter_posts_by_capability', 10, 1 );
function asp_filter_posts_by_capability( $results ) {
foreach ($results as $k => &$r ) {
if ( !current_user_can('read_post', $r->id) )
unset($results[$k]);
}
return $results;
}
If this does nothing, then you might have to ask the UM developers, if there is any programmatical way to check if the user can access a specific post, or to get the restricted post IDs, or get the restriction sub-query (if any). With that information I can recommend a custom code to integrate with.