Skip to content

Early-bird lifetime licence: $199 once, for the first 200 buyers only. See the offer

Replace “Howdy” in the admin bar

The admin bar greets users with just their name instead of “Howdy, name”.

  • Type PHP
  • Runs Everywhere (runs as WordPress loads)
  • Category Admin area
  • Tested with WordPress 7.1
PHP
<?php

add_action(
	'admin_bar_menu',
	static function ( $bar ) {
		$node = $bar->get_node( 'my-account' );
		if ( ! $node ) {
			return;
		}
		$user  = wp_get_current_user();
		$title = str_replace(
			/* translators: %s: current user's display name */
			sprintf( __( 'Howdy, %s' ), '<span class="display-name">' . $user->display_name . '</span>' ),
			'<span class="display-name">' . $user->display_name . '</span>',
			(string) $node->title
		);
		$bar->add_node(
			array(
				'id'    => 'my-account',
				'title' => $title,
				'meta'  => array_merge( (array) $node->meta, array( 'menu_title' => $user->display_name ) ),
			)
		);
	},
	9999
);

In these packs

  • More admin tweaks: Useful columns, a tidier admin bar, a welcome box for clients, and fewer menus for editors.

Move your snippets over this afternoon.

Importing changes nothing until you switch over, and your old shortcodes keep working.