Skip to content

Instantly share code, notes, and snippets.

@Tsunamijaan
Created January 5, 2019 09:15
Show Gist options
  • Select an option

  • Save Tsunamijaan/022cf9fb1c89ed859e93b7096c01e0a4 to your computer and use it in GitHub Desktop.

Select an option

Save Tsunamijaan/022cf9fb1c89ed859e93b7096c01e0a4 to your computer and use it in GitHub Desktop.
To Change Howdy text From WP Admin Bar
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,
),
) );
}
}
Note: Here replaced howdy text by welcome.======
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment