Posted By

FXDB on 11/29/11


Tagged

wordpress


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

jbyerson
jbreitenbucher


Change WordPress 3.3 Howdy text in the Admin Bar


 / Published in: PHP
 

Normally it says Howdy, Username. This shows how to change the Howdy text and replace it with Welcome. Add this snippet to Functions.php or create it as a site plugin.

  1. add_action( 'admin_bar_menu', 'wp_admin_bar_my_custom_account_menu', 11 );
  2.  
  3. function wp_admin_bar_my_custom_account_menu( $wp_admin_bar ) {
  4. $user_id = get_current_user_id();
  5. $current_user = wp_get_current_user();
  6. $profile_url = get_edit_profile_url( $user_id );
  7.  
  8. if ( 0 != $user_id ) {
  9. /* Add the "My Account" menu */
  10. $avatar = get_avatar( $user_id, 28 );
  11. $howdy = sprintf( __('Welcome, %1$s'), $current_user->display_name );
  12. $class = empty( $avatar ) ? '' : 'with-avatar';
  13.  
  14. $wp_admin_bar->add_menu( array(
  15. 'id' => 'my-account',
  16. 'parent' => 'top-secondary',
  17. 'title' => $howdy . $avatar,
  18. 'href' => $profile_url,
  19. 'meta' => array(
  20. 'class' => $class,
  21. ),
  22. ) );
  23.  
  24. }
  25. }

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: jbyerson on November 29, 2011

Nice snippet. Thanks.

You need to login to post a comment.