Quantcast
Channel: bbPress.org » All Posts
Viewing all articles
Browse latest Browse all 3669

Reply To: bbPress restricted search only for members

$
0
0

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 );
		}

	}

}

Viewing all articles
Browse latest Browse all 3669

Trending Articles