When developing a WordPress site when the client will have backend access, sometimes you want to customize parts of it to make it more targeted towards the client.

howdyThe ‘Howdy, [username]’ part of the admin bar has always annoyed me because of how unprofessional it is. As well, it doesn’t give an inexperienced user a hint that there is a menu under it. I’ve had many clients who are trying out WordPress on their own ask how to log out, and most never even though to click/hover over that Howdy message.

So, when setting up a site for a client, here’s the easy way to change this message just using a functions.php code.

Here’s the full code:

//change Howdy Message
add_action( 'admin_bar_menu', 'wp_admin_bar_howdygone', 11 );

function wp_admin_bar_howdygone( $wp_admin_bar ) {
$user_id = get_current_user_id();
$current_user = wp_get_current_user();
$profile_url = get_edit_profile_url( $user_id );

if ( 0 != $user_id ) {
/* Add the menu */
$avatar = get_avatar( $user_id, 28 );
$howdy = sprintf( __('Profile/Logout, %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,
'title'     => __('My Account Info'),
) );


For the most part, this just calls up the action of rendering the admin bar using the hook ‘admin_bar_menu’.

Steps To Make The Change

So first step is to open your functions.php file within your theme’s folder (need ftp access, or just in your admin editor under Appearance).  Then copy the code above, and paste at the bottom of the functions.php file.

The ‘$howdy’ part is really the only area that we need to be concerned with as its where you change the text that shows up in that area. Just change the [Profile/Logout,] part (minus the square brackets) to whatever you want it to say in the code. Many people just use ‘Welcome,’ instead of the Howdy part, but for when you need to be really straightforward with the users, i’d go with the basic ‘Profile/Logout’.  Be sure to leave the ‘%1$s’ part in there after the text you want, and before the apostrophe and bracket.


Change the Hover Title

The part that says

'title' => __('My Account Info'),

is the popup that shows up when you hover over the menu, and you can change the text in those quotes to whatever you want as well.

Remove The Avatar

Finally, if your users don’t use avatars, you’ll just have the standard blank WordPress box there. So, if you want to quickly just get rid of that area, change this line

'title' => $howdy . $avatar,

to this:

'title' => $howdy,

and the little avatar is gone!

Leave a Comment

Your email address will not be published. Required fields are marked *