1 Comment

Redirect Logged Out Visitors To Register, And Logged In Users To Profile Using A Dummy Page

Add the following code to bp-custom.php. See the commented instructions in the code to get it to work correctly.

// Before adding this code to bp-custom.php
// http://codex.buddypress.org/developer/customizing/bp-custom-php/
// you will need to create a new page in the dashboard and name it
// something like “Dummy Page” for example or any name you choose.
// Do not add this page to your menu because it is just a dummy page
// for the redirect. Then go to Dashboard/Settings/Reading.
// Under “Front page displays” select “A static page.” Then use the
// “Front page” drop-down menu to select the page you created. In my
// example for instance I selected “Dummy Page” for my front page.
// Done! Now logged out visitors get redirected to the register page,
// and logged in users get redirected to their profile.

/* Redirects to profile upon login, & logged out users are redirected to register page */
function bp_help_redirect_to_profile(){
if( is_user_logged_in() && bp_is_front_page() ) {
bp_core_redirect( get_option(‘home’) . ‘/members/’ . bp_core_get_username( bp_loggedin_user_id() ) . ‘/profile/’ );

}else {
if ( !is_user_logged_in() && !bp_is_register_page() && !bp_is_activation_page() )
bp_core_redirect( get_option(‘home’) . ‘/register/’);

add_action( ‘get_header’, ‘bp_help_redirect_to_profile’,1);


One comment on “Redirect Logged Out Visitors To Register, And Logged In Users To Profile Using A Dummy Page

  1. How would I change this so that it doesn’t redirect from home, but from a different page. For example, if I make a page called Community, with the slug community could I put that in the code instead, and then put the page in a menu and have users get redirected when clicking the menu?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: