Posted on September 15, 2013 , Last Modified on: September 15, 2013
Redirect logged out visitors to home, and logged in users to profile
// I was contacted by a BuddyDev user on how to accomplish this based on another
// code snippet I posted here so here is my solution. Add this code to bp-custom.php
// to redirect logged out visitors to the home page and redirect logged in users to
// their profile. Keep in mind that if you attempt to go to the home page while
// logged in then it will redirect you to your profile. Not tested with multisite!
// Enjoy!
function bp_help_redirect_to_profile(){
if( is_user_logged_in() && is_home() ) {
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() && !is_home() )
bp_core_redirect( get_option( 'home' ) );
}
}
add_action( 'template_redirect', 'bp_help_redirect_to_profile',1 );
#redirect-logged-out-vistors-home-and-logged-in-users-to-profile