get user first name of current user wordpress code example

Example 1: get current user first and last name wordpress

$current_user = wp_get_current_user();
    
    echo 'Username: ' . $current_user->user_login . '<br />';
    echo 'User email: ' . $current_user->user_email . '<br />';
    echo 'User first name: ' . $current_user->user_firstname . '<br />';
    echo 'User last name: ' . $current_user->user_lastname . '<br />';
    echo 'User display name: ' . $current_user->display_name . '<br />';
    echo 'User ID: ' . $current_user->ID . '<br />';

Example 2: wordpress get username

$current_user = wp_get_current_user();
echo($current_user->user_login);

Tags:

Php Example