fbpx

Get the Official WPSaviour App Now!

BlogTutorials

How to Change the Howdy Text in WordPress 3.3 Admin Bar

Have you ever worked with a client where you are trying to customize the WordPress back-end experience for them? Maybe you added a custom dashboard widget, removed menu items, or even created custom write panels. Well Greg Kerstin (@graphicagenda) was working on a project where he wanted to modify the howdy text in the WordPress admin bar. Normally it says Howdy, Username. He was kind enough to submit a snippet to us in which he shows how to change the howdy text and replace it with Welcome.

All you have to do is paste the following code in your theme’s functions.php file, or create a site plugin.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
add_action( 'admin_bar_menu', 'wp_admin_bar_my_custom_account_menu', 11 );
function wp_admin_bar_my_custom_account_menu( $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 "My Account" menu */
$avatar = get_avatar( $user_id, 28 );
$howdy = sprintf( __('Welcome, %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,
),
) );
}
}

And you are done.

Download The WPSaviour App Now

Related posts
Best WordPress PluginsBlog

WordPress 5.4 Will Add Lazy-Loading to All Images

Beginner’s GuideBlog

How to Add a Preloader Animation to WordPress (Step by Step)

BlogTutorials

Install WordPress On Ubuntu Locally With LAMP

BlogTutorials

Theme Customizer Boilerplate – Conditional Options, Child Themes and Plugins

Sign up for our Newsletter and
stay informed

Leave a Reply

Your email address will not be published.