Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save strangerstudios/cc30ee167aa7e3edeaa7 to your computer and use it in GitHub Desktop.
Save strangerstudios/cc30ee167aa7e3edeaa7 to your computer and use it in GitHub Desktop.
Hide bbPress forums protected with PMPro and PMPro bbPress from users who don't have access.
/*
By default pmpro-bbpress will hide topics and replies within a forum, but
will still show the member forums in the forums list.
You can use this code to hide forums from that list.
Note that you should tweak the post_type array there
if you are already using the "Filter Searches and Archives" option
to hide other post types.
*/
//function to tell PMPro to hide forums or also hide forums in searches
function my_pmpro_search_filter_post_types($post_types)
{
//$post_types = array("page", "post", "forums"); //use this one if you want to keep pages and posts out of searches also
$post_types = array("forum");
return $post_types;
}
add_filter('pmpro_search_filter_post_types', 'my_pmpro_search_filter_post_types');
//this line overrides the "Filter searches and archives?" advanced setting to turn it on
add_filter( 'pre_get_posts', 'pmpro_search_filter' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment