【发布时间】:2018-12-20 18:08:02
【问题描述】:
用户在 WordPress 中重置密码后如何获取新密码的哈希值?
我在我的 functions.php 文件中使用了钩子 after_password_reset,但 $user->user_pass 提供了 old 散列密码值(密码重置之前的散列密码),并且$new_pass 提供新密码的纯文本(未散列)。
我不明白为什么 $user->user_pass 提供旧密码,因为挂钩是在重置新密码后执行的。
示例代码:
function action_after_password_reset( $user, $new_pass ) {
$hashed_old_pass = $user->user_pass; // old hashed password, before password reset
$unhashed_new_pass = $new_pass; // plain text of new password, unhashed
};
add_action( 'after_password_reset', 'action_after_password_reset', 10, 2 );
获取存储在数据库中的新密码的准确哈希值对我来说很重要。我意识到我可以使用 wp_hash_password($new_pass) 来创建新密码的另一个哈希值,但我想要数据库中的确切哈希值。
【问题讨论】:
标签: wordpress hash passwords reset