How to Customize “Howdy” In WordPress Admin Bar [Quick Tip]

Every WordPress user should be familiar with the “Howdy” message that appears in the Admin Bar when they are logged in. The problem with “Howdy” is that it’s an informal word and sounds very unprofessional. Perhaps for some reason your client is given access to your WordPress Dashboard. If that’s the case, you might want to change it into a more proper greeting like “Welcome” for example.

In this post, we will cover how to do so. To top it off, we’ll also show you how to display a customized greeting for special public holidays like Christmas and New Year. If this sounds like an idea you have been wanting to execute for awhile now, let’s check out how it’s done.

Overwrite the “Howdy” Message

First, we want to overwrite the “Howdy”. Add these lines in the functions.php of your theme.

 function howdy_message($  translated_text, $  text, $  domain) { $  new_message = str_replace('Howdy', 'Welcome', $  text); return $  new_message; } add_filter('gettext', 'howdy_message', 10, 3); 

The above function replaces the “Howdy” with “Welcome” using the PHP str_replace function and applies the function through the WordPress own gettext filter. Once added, refresh the WordPress Dashboard and the greeting should now say “Welcome”, as shown below.

Special Holiday Greeting

Now we can make the greeting message more personalized. The idea is to greet the user during the holiday season. For example, if today was New Year, we would like to display Happy New Year followed by the user name. Likewise, if it were Christmas, we could wish the user with a Christmas greeting.

We need to get the month and the date. In PHP we can use date() function to retrieve the current date and month. Create a new function to call date() and output the result, like so.

 function public_holiday() { $  date = date('d-m'); } 

Assuming that today is 9th September, the output of this function would be 22-09. That is also to say that 01-01 is New Year, while 25-12 is Christmas. Having retrieved the date we can utilize it to set the greeting message, like so.

 function public_holiday() { $  date = date('d-m'); switch($  date) { case '01-01': $  message = 'Happy New Years'; break; case '25-12': $  message = 'Merry Christmas'; break; default: $  message = 'Welcome'; } return $  message; } 

As you can see above, we also set the default message to “Welcome” when the return value of the $ date does not fall to ’01-01′ or ’25-12′.

Now, we need to slightly change our previous function in order to show the message, like so.

 function howdy_message($  translated_text, $  text, $  domain) { $  message = public_holiday(); $  new_message = str_replace('Howdy', $  message, $  text); return $  new_message; } add_filter('gettext', 'howdy_message', 10, 3); 

Refresh the WordPress Dashboard once again. And if it is New Year or Christmas you should see the Howdy message change into what you’ve specified as per below.

More Ideas

There are more cool ideas that we can achieve. Some examples of what you can do to improve this particular area of WordPress includes adding more special holiday greetings like for Eid or by displaying a localized greeting based on the users’ current location or language preference. All you need is some creativity and basic understanding on PHP and WordPress functions, classes, and hooks.

Leave a Comment