Hi @4briang,
Thank you for your message.
You don’t need to use the acfbs_search_is_available filter to do what you want to do. Just use the code you provided below and it should work without a problem.
Best,
Mateusz
Wow, thanks for the quick answer. That isn’t working for me but this one is so I’m covered. Thanks again.
add_filter( 'pre_get_posts', 'exclude_pages_search_when_logged_in' );
function exclude_pages_search_when_logged_in($query) {
if ( $query->is_search && is_user_logged_in() )
$query->set( 'post__not_in', array( 11, 22, 33, 44, 55 ) );
return $query;
}
@4briang This issue has nothing to do with my plugin. My plugin plugs into the WordPress search engine, so all WordPress hooks should work without problems.
In your function you declare that I would like to exclude posts when logged in search. What exactly would you like to achieve?
@mateuszgbiorczyk Thanks for the reply. I didn’t say anything was broken with your plugin. I’m sure there’s another reason the author filter wasn’t working. I actually want to hide specific posts if a user is not logged in. So that was simple enough with a quick change to the filter. You can close this thread for my purposes although I appreciate you making sure I’m set.
// remove posts from search if user is not logged in
add_filter( 'pre_get_posts', 'exclude_pages_search' );
function exclude_pages_search($query) {
if ( $query->is_search && !is_user_logged_in() )
$query->set( 'post__not_in', array( 11, 22, 33, 44, 55 ) );
return $query;
}