Skip to:
Content
Pages
Categories
Search
Top
Bottom

Show only topics to public visitors.


  • Anand
    Participant

    @anandkumar4u

    Hello All,

    I am trying to hide all the replies for anonymous or public. I added the following code:

    
    function custom_bbp_show_lead_topic( $show_lead ) {
    $show_lead[] = 'true';
    return $show_lead;
    }
    
    add_filter('bbp_show_lead_topic', 'custom_bbp_show_lead_topic' );
    
    function remove_forum_replies_guest() {
    	if ( !is_user_logged_in() ) {
    		remove_action('bbp_before_has_replies_parse_args', 'bbp_replies') ;
    	} 
    }
    
    add_filter('bbp_has_replies_query',  'remove_forum_replies_guest');

    It removes all the replies not only for public (non-logged in visitors) but also from logged in users.

    Any help will be appreciated.

Viewing 2 replies - 1 through 2 (of 2 total)

  • Anand
    Participant

    @anandkumar4u

    OK. I figured out the problem.

    The code should be:

    function custom_logged_in_topics($have_posts){
        if (!is_user_logged_in()){
            $have_posts = null;
      	    echo 'Login to see replies';
        }
        return $have_posts;
    }
     
    add_filter('bbp_has_topics', 'custom_logged_in_topics');
    add_filter('bbp_has_forums', 'custom_logged_in_topics');
    add_filter('bbp_has_replies', 'custom_logged_in_topics');

    Got from earlier thread. (That code was not working because of backtick instead on ‘ or “)


    Lifeischoice
    Participant

    @lifeischoice

    Hello,
    newbie question: Need assistance to change your code above so as to hide replies by the keymaster (admin) only for public or non logged in?

    thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Skip to toolbar