Created
January 26, 2022 18:14
-
-
Save kerijacoby/3134238bf3287fa2dd598964a5e6b6ef to your computer and use it in GitHub Desktop.
bbPress Hide Forums From Members If Member Does Not Have Access To Level
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* By default the pmpro-bbpress add on 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 if the logged in member | |
* does not have access to that forum. | |
*/ | |
//Tell PMPro to hide forums if member does not have access. | |
function my_pmpro_search_filter_post_types( $post_types = array( 'page', 'post' ) ) | |
{ | |
$post_types[] = '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?" setting under | |
* Membership > Settings > Advanced > Content Settings to make active | |
*/ | |
add_filter( 'pre_get_posts', 'pmpro_search_filter', 99 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment