I am trying to find a WordPress action hook that will allow me to access a new user's wp_usermeta information, immediately after the user has been created. In our registration process, custom fields are entered along with the standard WordPress user fields. So far, I've tried using the hook user_register
, but that doesn't work. I sort of expected user_register
wouldn't work, because its codex entry says:
https://codex.wordpress.org/Plugin_API/Action_Reference/user_register
"Not all user meta data has been stored in the database when this action is triggered. For example, nickname is in the database but first_name and last_name are not (as of 3.9.1)"
And this has turned out the be the case. My function does not return any user meta data if I use the user_regsiter
hook.
The general outline of my function is:
add_action( 'user_register', 'myfunction', 10, 1 );
function myfunction ( $userid ) {
$user_object = get_userdata( $userid );
$user_fields = array(
//this is returned when using user_register hook
$user_object->user_login,
//this is *not* returned when using user_register hook
$user_object->some custom field
);
//do stuff with $user_fields array
}
So my question is, what hook can I use that fires after a user has registered, AND after their user meta data has been written to wp_usermeta ?