How to Remove WordPress 'Howdy, User' from WordPress AdminBar

Do you need to try a WordPress plugin? Create a temp site now!

Sharing is caring!

After the user logs into WordPress, they will see the top admin bar. It has lots of menu opens depending on the currently logged in user's role.

One of the things that is really not necessary is the Howdy text shown in the top right corner.

Wp Howdy Admin Bar

the following code can be used to remove the howdy text. This would work if the site is in English. If you're using a different language feel free to add other options separated by the pipe character. The fix is nice because it also removes exclamation and spaces so it makes it cleaner.

<?php

// it turns out having a lower priority than 10000 doesn't remove the howdy text
add_filter( 'admin_bar_menu', 'wpsandbox_rm_howdy_admin_bar', 10000 );

/**
 * Clears the howdy text from the WordPress adminbar (right-hand side)
 * @see https://wpsandbox.net/1535
 */
function wpsandbox_rm_howdy_admin_bar( $wp_admin_bar ) {
	$my_account = $wp_admin_bar->get_node('my-account');

	if (!empty($my_account->title)) { // logged in user
		$new_title = preg_replace( '#[\s\!]*(Howdy|welcome)[\s\,\!]*#si', '', $my_account->title );

		$wp_admin_bar->add_node( array(
			'id'    => 'my-account',
			'title' => $new_title,
		) );
	}
}

Make sure you package this php code as a plugin. You can use our free WordPress Plugin Generator as well.

You can of course add this to your functions.php file but you'll have to remove the <?php tag as there's such tag already.

How it works is it gets the menu element with internal id: my-account and then uses php regular expression to modify the title and then it adds it as a new node but because we're passing the id it overrides the previous entry.

Having less things in the menu makes it cleaner and more professional.

Sharing is caring!

Do you need to try a WordPress plugin? Create a temp site now!
This code shared in this post/site is provided "AS IS" without any warranties or guarantees of any kind. The authors and distributors of this code cannot be held responsible for any damage, data loss, or other issues that may arise from its use. It is strongly recommended that you test this code in a staging environment before deploying it to a live site. Always ensure you have proper backups and understand the implications of running this code on your WordPress installation. Use at your own risk.

Leave a Comment

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

The new new server is up and running. Enjoy!