钩子文档

password_reset_key_expired

💡 云策文档标注

概述

password_reset_key_expired 是一个 WordPress 过滤器钩子,用于在 check_password_reset_key() 函数检测到旧式或过期密码重置密钥时,过滤其返回值。开发者可以通过此钩子自定义处理过期密钥的逻辑。

关键要点

  • 此钩子在 check_password_reset_key() 函数中使用,当密钥过期或为旧式时触发。
  • 参数包括 $return(一个表示过期密钥的 WP_Error 对象)和 $user_id(匹配的用户 ID)。
  • 返回一个 WP_User 对象可以验证密钥,允许开发者覆盖默认的过期处理。
  • 源代码为 apply_filters( 'password_reset_key_expired', $return, $user_id )。
  • 相关函数是 check_password_reset_key(),用于基于密码重置密钥和登录名检索用户行。
  • 变更历史:WordPress 4.3.0 之前密钥哈希存储无过期时间,3.7.0 版本引入此钩子。

📄 原文内容

Filters the return value of check_password_reset_key() when an old-style key or an expired key is used.

Parameters

$returnWP_Error
A WP_Error object denoting an expired key.
Return a WP_User object to validate the key.
$user_idint
The matched user ID.

Source

return apply_filters( 'password_reset_key_expired', $return, $user_id );

Changelog

Version Description
4.3.0 Previously key hashes were stored without an expiration time.
3.7.0 Introduced.