0

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.

0

I'm not entirely clear on what you're trying to do, but it seems you want to pass the user's email address via a query string and determine the user by that. You can get the user's ID for writing user meta values from the email value. Use the function get_user_by() to retrieve the user object by the user's email.

$email = ( isset( $_GET['login'] ) ) ? $_GET['login'] : false;

$user = get_user_by( 'email', $email );

if ( $user ) {
    update_user_meta( $user->ID, 'meta_key_to_save', $value );
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.