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


// PLEASE NOTE FOR THIS TO WORK: // 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, and 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);

#redirect