Reply To: [Resolved] Link “Howdy” to Wall
@skyrie, You’ve probably already figured this out by now, but in case anyone else wants to know how to do this, you can put this code in your functions.php:
function my_admin_bar_change_howdy_target( $wp_admin_bar ) {
$user_id = get_current_user_id();
$current_user = wp_get_current_user();
$profile_url = get_edit_profile_url( $user_id );
if (substr($profile_url, -5) == 'edit/') {
$profile_url = substr($profile_url, 0, -5);
}
if ( 0 != $user_id ) {
/* Add the "My Account" menu */
$avatar = get_avatar( $user_id, 28 );
$howdy = sprintf( __('Howdy, %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,
),
) );
}
}
add_action( 'admin_bar_menu', 'my_admin_bar_change_howdy_target', 11 );
Also I’d love to hear suggestions for better ways of doing this, in case anyone has any.