In WordPress, when a user is logged in, the admin bar in the top right corner of the screen greets the user with “Howdy, [Username].” It’s great that WordPress is so friendly! But personally, I find it a little odd, and it takes up precious real estate in the admin bar. It’s a simple thing, and it doesn’t make much difference, but sometimes little things are important too. So I thought I would show you how to remove this on your Divi websites. In this tutorial, I will show you how to remove the word “howdy” from before the username in the WordPress admin bar in Divi.
Add A PHP Code Snippet To Remove Howdy From The WordPress Admin Bar
The quick and simple way to do this is with the PHP code snippet below. We have instructions in the toggle below for where to paste PHP code if you are not familiar with it. Just remember to be careful, as PHP can cause issues if not implemented properly. After adding this snippet to your site, you can refresh the page and the word “howdy” should be removed from the admin bar.
Where To Paste The PHP Code
1. Divi Assistant
If you are using our Divi Assistant plugin, simply paste the code in the PHP tab in the custom code window in the Divi Visual Builder.
2. Child Theme
If you are using a child theme, paste this code into the functions.php file. If you don't have a child theme, you can generate a child theme directly on your site or download our free child theme.
3. Code Snippet Plugins
Otherwise, install a dedicated code snippet plugin, create a new snippet, and paste this code into the PHP code editor.
If you need help understanding where to paste the code, please check out our complete guide about where to add custom PHP code snippets in Divi.
/**
* Customize the user name displayed in the WordPress admin bar.
*/
function pac_da_custom_admin_bar_user_name() {
global $wp_admin_bar;
// Define the ID of the node representing the "My Account" section in the admin bar.
$node_id = 'my-account';
// Check if the specified node exists in the admin bar.
if ($wp_admin_bar->get_node($node_id)) {
// Get the current title of the "My Account" section.
$current_title = $wp_admin_bar->get_node($node_id)->title;
// Split the current title into an array based on the comma and space separator.
$newTitle = explode(", ", $current_title);
// Update the "My Account" section title with the second part of the split title if available,
// otherwise keep the current title.
$wp_admin_bar->add_node(array(
'id' => $node_id,
'title' => isset($newTitle) && isset($newTitle[1]) ? $newTitle[1] : $current_title,
));
}
}
// Hook the custom admin bar user name function to run before the admin bar is rendered.
add_action('wp_before_admin_bar_render', 'pac_da_custom_admin_bar_user_name');
Code Explanation
This code snippet removes the word “Howdy” from the WordPress username in the admin bar. This function modifies the greeting by removing the “Howdy” part, leaving just the username visible in the admin bar. It achieves this by intercepting the rendering of the admin bar and adjusting the displayed username accordingly.
How To Remove The Word “Howdy” From the WordPress Admin Bar Using Divi Assistant
Here are the simple steps to remove the word “Howdy” from the WordPress admin bar using our popular Divi Assistant plugin:
- Install and activate the Divi Assistant plugin
- Click on the Utility Helper tab and the Admin Bar subtab
- Enable the setting
I hope that is easy enough for you! 😉
![how to Remove “Howdy” From Before user Name In Admin Bar using the Divi Assistant plugin how to Remove “Howdy” From Before user Name In Admin Bar using the Divi Assistant plugin](https://www.peeayecreative.com/wp-content/uploads/2024/03/how-to-Remove-Howdy-From-Before-user-Name-In-Admin-Bar-using-the-Divi-Assistant-plugin.png)
0 Comments