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
Goodmorning Ernest,
I think i found in the heir documents the correct fuction. It is called user_can(). https://ultimatemember.com/php-docs/classes/um.core.Access.html#source-view
If you click on the </> Icon, a popup will appear with the code of a template called access.php. In line 179 you can see how they use this function. I think this is what we need?
I tried changing your code into this
add_filter( ‘asp_results’, ‘asp_filter_posts_by_capability’, 10, 1 );
function asp_filter_posts_by_capability( $results ) {
foreach ($results as $k => &$r ) {
if ( !user_can(get_current_user_id(), $restriction[‘_um_access_roles’]) )
unset($results[$k]);
}
return $results;
}
But it just broke the seach results completely… No pages were found regardless their restriction status… When I removed the ! from !user_can(… , then the search results appeared again, of course unfiltered (restricted pages were still shown).