Skip to:
Content
Pages
Categories
Search
Top
Bottom

Hide replies only for guests


  • paulmist
    Participant

    @paulmist

    Hi,

    I’d like to be able to hide replies (not original post/topic) from guests.

    Is this possible?

    Thanks

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

  • wpturk
    Participant

    @wpturk

    This should do the job: (put this in your functions.php)

    function bb_auth_reply_view( $reply_id ) {
            $reply_id = bbp_get_reply_id( $reply_id );
    
            // Check if password is required
            if ( post_password_required( $reply_id ) )
            return get_the_password_form();
    
            $content = get_post_field( 'post_content', $reply_id );
    
            // first topic reply shouldn’t be hiding
            $rep_position = bbp_get_reply_position($reply_id);
    
            // if user is not logged in and not the first post topic
            if( !is_user_logged_in() ) {
                    return "Replies only viewable for logged in users";
            } else {
                    // return normal
                    return $content;
            }
    
    }
    add_filter( 'bbp_get_reply_content', 'bb_auth_reply_view' );

    paulmist
    Participant

    @paulmist

    This works great with a minor tweak…

    if( !is_user_logged_in() && $rep_position > 1 )

    However – is it possible to hide replies and not just their content?

    Tried using bbp_get_reply as a filter with no luck.

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