Skip to:
Content
Pages
Categories
Search
Top
Bottom

bbPress restricted search only for members


  • nicolaiwh
    Participant

    @nicolaiwh

    Hi all, very new to this!

    I have setup a bbPress forum and my front page has two separate search boxes (one on the top and one to the right)

    Both of these searchboxes return search results for non-members (although they cannot click the search results once they appear) is there a way to remove search results for users who have not signed in/managed to find a way to our forum?

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

  • regnalf
    Participant

    @regnalf

    I need this functionality too, no answers yet?


    Robin W
    Moderator

    @robin-w

    if forums are private then bbpress search should only show results to logged in users


    regnalf
    Participant

    @regnalf

    Ok, can i restrict this more for a specific user role?

    Actually i want to have a forum that is for special members only. So nothing should be visible, accessable or should be found without a special role.


    Robin W
    Moderator

    @robin-w


    regnalf
    Participant

    @regnalf

    WOW, Thanks for that fast reply!!! I will check it out.

    Thank you


    regnalf
    Participant

    @regnalf

    bbpress private groups does a good job to hide forums, but that still doesn’t remove the index page. if anyone needs to restrict the index page for a complete private forum, here is the code:

    add_action( 'wp', 'restrict_bbpress' );
    function restrict_bbpress()
    {
    
    	global $wp;
    	global $wp_query;	
    	
    	$bbpress_index = get_option ('_bbp_root_slug');
    	
    	if ($wp->request == $bbpress_index)
    	{
    
    		$user = get_userdata(get_current_user_id());
    		
    // Example for a user role member
    		if (! is_user_logged_in() || 
    		    ! in_array( 'member', (array) $user->roles ))
    		{
    			$wp_query->set_404();
    			status_header( 404 );
    		}
    
    	}
    
    }

    regnalf
    Participant

    @regnalf

    use if(strpos($wp->request, $bbpress_index) !== false) if you also want to restrict all possible sub-urls!

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