BuddyPress BP admin bar mod work.

Problem with buddypress admin bar login functionality.

When a visit comes to a WPMU site and clicks on the login link at the bp admin bar the default function is to direct them to the primary domain login page.

Once they login they are then directed to the primary domain homepage. The user can still login to there admin panel at that point but it causes the user to have to login again at their own domain.

This is not ideal functionality with mapped domains.

I modded the bp-core-adminbar.php file temporarily to test  a alternate method for the login url. Thus far is seems to work.

//echo ‘<li><a href=”‘ . $bp->root_domain . ‘/wp-login.php?redirect_to=’ . urlencode( $bp->root_domain ) . ‘”>’ . __( ‘Log In’, ‘buddypress’ ) . ‘</a></li>’;
echo ‘<li><a href=”/wp-login.php?redirect_to=’ . urlencode( ‘http://’.$_SERVER[“HTTP_HOST”].’/wp-admin’) . ‘”>’ . __( ‘Log In’, ‘buddypress’ ) . ‘</a></li>’;

This seems to change the behavior so when the visitor clicks on the login page. They are redirected to the same url. Once they are logged in it directs them into there admin area. Seems more logical.

End plugin looks like this

// **** “Log In” and “Sign Up” links (Visible when not logged in) ********
function custom_bp_adminbar_login_menu() {
global $bp;

if ( is_user_logged_in() )
return false;

//echo ‘<li><a href=”‘ . $bp->root_domain . ‘/wp-login.php?redirect_to=’ . urlencode( $bp->root_domain ) . ‘”>’ . __( ‘Log In’, ‘buddypress’ ) . ‘</a></li>’;
echo ‘<li><a href=”/wp-login.php?redirect_to=’ . urlencode( ‘http://’.$_SERVER[“HTTP_HOST”].’/wp-admin’) . ‘”>’ . __( ‘Log In’, ‘buddypress’ ) . ‘</a></li>’;
// Show “Sign Up” link if user registrations are allowed
if ( bp_get_signup_allowed() ) {
echo ‘<li><a href=”‘ . bp_get_signup_page(false) . ‘”>’ . __( ‘Sign Up’, ‘buddypress’ ) . ‘</a></li>’;
}
}

function my_alter_bp_adminbar() {
remove_action( ‘bp_adminbar_menus’, ‘bp_adminbar_login_menu’,2);
add_action( ‘bp_adminbar_menus’, ‘custom_bp_adminbar_login_menu’, 2 );
}

// Modify BP Login
add_action(‘wp_footer’,’my_alter_bp_adminbar’,1);

Leave a Reply