How to Change the Howdy Text in WordPress 3.3 Admin Bar

54

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.

Change Howdy to Welcome

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

  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.

Social Media Auto Publish Powered By : XYZScripts.com