Skip to content

Instantly share code, notes, and snippets.

@shanebp
Last active August 29, 2015 14:11
Show Gist options
  • Save shanebp/91acc541776cc083e3a5 to your computer and use it in GitHub Desktop.
Save shanebp/91acc541776cc083e3a5 to your computer and use it in GitHub Desktop.
In the wp-toolbar, change the Howdy and Name links so they don't go to profile/edit
// change the Howdy and Name links so they don't go to profile/edit
function wp_admin_bar_my_custom_account_menu( $wp_admin_bar ) {
$user_id = get_current_user_id();
$current_user = wp_get_current_user();
$profile_url = bp_loggedin_user_domain();
if ( 0 != $user_id ) {
$avatar = get_avatar( $user_id, 28 );
$howdy = sprintf( __('Welcome, %1$s'), $current_user->display_name );
$class = empty( $avatar ) ? '' : 'with-avatar';
$wp_admin_bar->add_menu( array(
'id' => 'my-account',
'parent' => 'top-secondary',
'title' => $howdy . $avatar,
'href' => $profile_url,
'meta' => array( 'class' => $class, ),
) );
$user_info = get_avatar( $user_id, 64 );
$user_info .= "<span class='display-name'>{$current_user->display_name}</span>";
$wp_admin_bar->add_menu( array(
'parent' => 'user-actions',
'id' => 'user-info',
'title' => $user_info,
'href' => $profile_url,
'meta' => array( 'tabindex' => -1, ),
) );
}
}
add_action( 'admin_bar_menu', 'wp_admin_bar_my_custom_account_menu', 11 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment