Skip to:
Content
Pages
Categories
Search
Top
Bottom

Reply To: forums/users/ only for logged in users?

@robkk

Moderator

You can use this php Code function instead if you are not using BuddyPress. Make sure to place it in your child themes functions.php file or in a functionality plugin.

What it does is redirect non-logged in users from see user profile pages to the default WordPress login page.

You can change the page by editing

site_url('wp-login.php');

to something like this if you have a yoursite.com/login page instead.

site_url('/login/');

function rkk_restrict_bbp_user_pages() {

    if ( ! is_user_logged_in() ) {

       if ( bbp_is_single_user() ) {

                    $url = site_url('wp-login.php');

                        // Send them to the new URL
                    wp_redirect( $url );

                    exit;
	}
    }
}
add_action( 'template_redirect', 'rkk_restrict_bbp_user_pages');
Skip to toolbar