我需要在密码更新之前和之后捕获哈希密码。使用
add_action( 'profile_update', 'updatePassword', 10, 2 );
我能够成功捕获它。我如何使用 -
实现它add_action( 'password_reset', 'resetPassword',10,2)
还有其他方法可以实现。
-
您可以通过在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 }
-
您可以在after_password_reset上获得新密码
add_action( 'after_password_reset', 'afterResetPassword', 10, 2 ); function afterResetPassword( $user, $new_pass ) { //Code for saving your new user data }
尝试以下内容:
<?php
add_action( 'password_reset', 'my_password_reset', 10, 2 );
function my_password_reset( $user, $new_pass ) {
// Do something before password reset.
}
?>
在功能中设置了您想做的逻辑
源