How to Change the Howdy Text in WordPress 3.3 Admin Bar

By WP Saviour •  Updated: 10/01/20 •  2 min read

Have you ever ever labored with a consumer the place you are attempting to customise the WordPress back-end expertise for them? Possibly you added a custom dashboard widget, removed menu items, and even created custom write panels. Properly Greg Kerstin (@graphicagenda) was engaged on a undertaking the place he needed to switch the howdy textual content within the WordPress admin bar. Usually it says Howdy, Username. He was type sufficient to submit a snippet to us wherein he reveals methods to change the howdy textual content and substitute it with Welcome.

All you must do is paste the next code in your theme’s features.php file, or create a website 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 );

perform 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 ) {

$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',

'dad or mum' => 'top-secondary',

'title' => $howdy . $avatar,

'href' => $profile_url,

'meta' => array(

'class' => $class,

),

) );

}

}

And you might be completed.

gp-4365523 as-8845938

WP Saviour