1
votes

The user have metadata called "pin", I need hook of "Reset password" form submit:

I found where validate is checked, I need hook to add my pin validate here: https://github.com/woocommerce/woocommerce/blob/master/includes/shortcodes/class-wc-shortcode-my-account.php#L293

WooCommerce endpoint: example.com/my-account/lost-password

enter image description here

I need check if the user filled in the field with a PIN, and I need intercept default reset password function and check if are a valid PIN, and return a valid data to WooCommerce continue process to reset password.

I do this to login with add_filter( 'authenticate', 'validateLoginByPin'); but I don't know what I need to filter to reset password. The logic to check are done, but I need correct hook:

function resetPasswordByPin($submitedUser) {

    if(isset($submitedUser) && is_numeric($submitedUser)) {
        $pin = $submitedUser;

        $existUser = get_users(
            array(
                'meta_key' => 'pin',
                'meta_value' => $pin,
            )
        );

        if(!empty($existUser) && isset($existUser[0]->data->user_email)) {
            return $existUser[0]->data->user_email; // return e-mail or some valid data to woocommerce continue process...
        }

    }
    return $submitedUser;

}
add_filter('i_dont_know_function_name', 'resetPasswordByPin');

How can I do this without edit core files?

1

1 Answers

0
votes

I think you are looking for password_reset hook.