My login process is exactly like this:
1- user put email in the form
2- a link sent to email for setting password
3- user click on the link and redirect to website with code like this: https://www.example.com/my-account/?action=rp&key=oH02AnKdf3xGAU9TvAVew&login=email@example.com
Now in this new form, I'm trying to capture the password and put it into the meta data table; but I can;t detect which user ID is logged in to the website.
My code was this for registration before I changed the registration process:
add_action( 'user_register', 'myplugin_registration_save', 10, 1 );
function myplugin_registration_save( $user_id ) {
update_user_meta($user_id, 'user_pass2', (string) $_POST['pass2']);
}
And for updating the password, I used this hook:
add_action( 'profile_update', 'my_profile_update' );
But they both used when the user actually logged in and post some data.