Feature Suggestion: Don’t just disable Howdy, replace it with a better greeting

I got fed up with the default ‘Howdy’ message a long time ago but wanted to have something more than just a clients name over in the top right of their screen. It was then that I came up with the following modification.

Professionalism is needed on a clients site and I feel that this would be a well deserved feature to add to ASE.

// Greet user with Good Morning, Afternoon or Evening depending on the time of day
function ctm_replace_howdy( $wp_admin_bar ) {
    // Get the current hour
    $current_hour = date( 'H' );

    // Define the greetings based on the time of day
    if ( $current_hour < 12 ) {
        $greeting = 'Good Morning';
    } elseif ( $current_hour < 18 ) {
        $greeting = 'Good Afternoon';
    } else {
        $greeting = 'Good Evening';
    }

    // Get the node
    $my_account = $wp_admin_bar->get_node( 'my-account' );

    // Extract the username from the title
    preg_match( '/^(.*),(.*)$/', $my_account->title, $matches );
    $username = trim( $matches[2] );

    // Construct the new title with the updated greeting
    $new_title = $greeting . ', ' . $username;

    // Update the title
    $my_account->title = $new_title;

    // Add the updated node
    $wp_admin_bar->add_node( array(
        'id'    => 'my-account',
        'title' => $my_account->title,
    ) );
}
add_filter( 'admin_bar_menu', 'ctm_replace_howdy', 25 );

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer