Short answer to “Which property am I supposed to use“: Use first_name and last_name.
Longer answer:
The properties first_name, user_firstname, last_name and user_lastname are defined in the WP_User class, and despite the different names (i.e. one with user_ and the other without that prefix):
- Both
first_nameanduser_firstnameuse the value of thefirst_namemeta. - Both
last_nameanduser_lastnameuse the value of thelast_namemeta.
But user_firstname and user_lastname were the property names used in WordPress prior to version 2.0.0 (14 years ago..) — see get_the_author_firstname() and get_the_author_lastname() here and here, and that properties are still supported for backward compatibility, but we should just use the ones without the user_ prefix (e.g. first_name and not user_firstname).
// Both of these return the same value - the value of the meta named first_name.
var_dump(
get_the_author_meta( 'user_firstname' ), // works
get_the_author_meta( 'first_name' ) // but better
);
// Both of these return the same value - the value of the meta named first_name.
$current_user = wp_get_current_user();
var_dump(
$current_user->user_firstname, // works
$current_user->first_name // but better/shorter...
);