Hide private forum topics from public search?
-
Hello,
I have found a code snippet somewhere, that does a fine job by including forum topics in the ordinary WP search. The only problem is that I have now added some private forums on the site where teachers can share assignments and problem statements for use in class.
So I would like to exclude private forum topics and replies from search results unless you are logged in as ‘contributor’ and up.
Does anybody know how to code that?
My code snippet is here:
/** * Include bbPress 'topic' custom post type in WordPress' search results */ function ntwb_bbp_topic_cpt_search( $topic_search ) { $topic_search['exclude_from_search'] = false; return $topic_search; } add_filter( 'bbp_register_topic_post_type', 'ntwb_bbp_topic_cpt_search' ); /** * Include bbPress 'forum' custom post type in WordPress' search results */ function ntwb_bbp_forum_cpt_search( $forum_search ) { $forum_search['exclude_from_search'] = false; return $forum_search; } add_filter( 'bbp_register_forum_post_type', 'ntwb_bbp_forum_cpt_search' ); /** * Include bbPress 'reply' custom post type in WordPress' search results */ function ntwb_bbp_reply_cpt_search( $reply_search ) { $reply_search['exclude_from_search'] = false; return $reply_search; } add_filter( 'bbp_register_reply_post_type', 'ntwb_bbp_reply_cpt_search' );
Thanks.
Current WordPress and bbPress
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- You must be logged in to reply to this topic.