Skip to:
Content
Pages
Categories
Search
Top
Bottom

Reply To: [Resolved] Admin Bar Login Redirects To Main Site & Not Current Blog


deadlyhifi
Participant

@tomdebruin

I’ve just experienced this and have come up with a fix:

function custom_bp_adminbar_login_menu() {
global $bp;

if ( is_user_logged_in() )
return false;

$redirecturl = $bp->root_domain . '/wp-login.php?redirect_to=' . urlencode( $bp->root_domain ) . esc_url( $_SERVER );
echo '
' . __( 'Log In', 'buddypress' ) . '

';

// Show "Sign Up" link if user registrations are allowed
if ( bp_get_signup_allowed() ) {
echo '
' . __( 'Sign Up', 'buddypress' ) . '

';
}
}
remove_action( 'bp_adminbar_menus', 'bp_adminbar_login_menu', 2 );
add_action( 'bp_adminbar_menus', 'custom_bp_adminbar_login_menu', 2 );

Drop that into your functions.php file.

It’s the same as the standard function except it appends the $bp->root_domain with $_SERVER.
I’m not sure if this is a feature or something that’s been overlooked and needs reporting in trac. Also on different servers I’ve had differing results with php $_SERVER based stuff so I’m not sure if it will work everywhere. It works on the server I’m using anyway.

Skip to toolbar