Skip to content

Instantly share code, notes, and snippets.

@anandkumar
Created December 24, 2013 16:04
Show Gist options
  • Save anandkumar/8115124 to your computer and use it in GitHub Desktop.
Save anandkumar/8115124 to your computer and use it in GitHub Desktop.
bbPress limit content visibility for non-logged in user
// Display Topic Leads
add_filter('bbp_show_lead_topic', 'custom_bbp_show_lead_topic' );
function custom_bbp_show_lead_topic( $show_lead ) {
if ( !is_user_logged_in() ){
$show_lead[] = 'true';
return $show_lead;
}}
// Show Topic Leads to Public or Anonymous visitors
add_filter('bbp_has_replies', 'synth_logged_in_topics');
function synth_logged_in_topics($have_posts){
if ( !is_user_logged_in() ){
$have_posts = null;
echo '<h4 class="login-first alert">This is a private forum.</h4>';
}
return $have_posts;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment