Change display username to display first name

[ad_1]

Hey,

We have created a filter hook for this. If you want to change the username which is showing in the navigation.

You can modify the given code accordingly.

Helping Documentation: https://loginpress.pro/doc/login-logout-menu-filters/

/**

* Filter to Change the user profile link text

*

* @param [String] $user_name The name of the user who is logged in

*

* @return [string] Custom String and the username

*/

add_filter( 'login_logout_menu_username', 'custom_loginpress_login_logout_menu_username' );

function custom_loginpress_login_logout_menu_username( $user_name ) {

$current_user = null !== wp_get_current_user() && ! empty( wp_get_current_user() ) ? wp_get_current_user()->display_name : $user_name;

return $current_user;

}

Kindly copy and paste the following in your theme’s functions.php file.

This code will modify the username to display name.

Have a nice day!

 

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