简体   繁体   中英

Wordpress get old and new user details on password_reset hook

I need to capture the hash password before and after password update. Using

add_action( 'profile_update', 'updatePassword', 10, 2 );

I am able to successfully capture it. How do I achieve it using -

add_action( 'password_reset', 'resetPassword',10,2)

Is there some other method to achieve so the same.

  1. You can get old password hash by using wp_get_current_user() on pssword_reset

    add_action('password_reset', 'resetPassword', 10, 2); function resetPassword( $user, $new_pass ) { $oldUser = wp_get_current_user(); //Code for saving your old user data }
  2. You can get new password hash on after_password_reset

    add_action( 'after_password_reset', 'afterResetPassword', 10, 2 ); function afterResetPassword( $user, $new_pass ) { //Code for saving your new user data }

try the following :

<?php

    add_action( 'password_reset', 'my_password_reset', 10, 2 );

    function my_password_reset( $user, $new_pass ) {
        // Do something before password reset.
    }
?>

and in the function set the logic that you wish to do

source

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM