简体   繁体   English

Wordpress 在 password_reset 挂钩上获取新旧用户详细信息

[英]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您可以通过在 pssword_reset 上使用 wp_get_current_user() 来获取旧密码哈希

    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您可以在 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 来源

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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