I'm trying to access the $user->first_name property from a function triggered by the register_user
action hook but it's not there:
function do_stuff($user_id) {
$new_user = get_userdata($user_id);
$first_name1 = $new_user->user_firstname;
$last_name1 = $new_user->user_lastname;
echo "<" . $first_name1 . $last_name1 . ">";
//returns: <>
$first_name2 = $new_user-first_name;
$last_name2 = $new_user->last_name;
echo "<" . $first_name2 . $last_name2 . ">";
//returns: <>
}
add_action("register_user", "do_stuff");
UPDATE:
I tried this:
$user_meta = get_user_meta( $new_user->ID );
var_dump($user_meta);
and I got this (last_name and first_name are empty even though they're defined in the user's profile):
array(11) { ["wp_user_level"]=> array(1) { [0]=> string(1) "0" } ["show_admin_bar_front"]=> array(1) { [0]=> string(4) "true" } ["wp_capabilities"]=> array(1) { [0]=> string(32) "a:1:{s:10:"subscriber";s:1:"1";}" } ["use_ssl"]=> array(1) { [0]=> string(1) "0" } ["admin_color"]=> array(1) { [0]=> string(5) "fresh" } ["comment_shortcuts"]=> array(1) { [0]=> string(5) "false" } ["rich_editing"]=> array(1) { [0]=> string(4) "true" } ["description"]=> array(1) { [0]=> string(0) "" } ["nickname"]=> array(1) { [0]=> string(7) "emerson" } ["last_name"]=> array(1) { [0]=> string(0) "" } ["first_name"]=> array(1) { [0]=> string(0) "" } }