Filter posts (or CPT) which user can’t access
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;
}PreviousLimit results to specific post IDs onlyNextRestricting results by user Groups using the Groups plugin by itthinx
Last updated