check_password
云策文档标注
概述
check_password 是一个 WordPress 过滤器,用于在验证明文密码与哈希密码是否匹配时进行干预。它允许开发者自定义密码验证逻辑,例如添加额外的安全检查或修改匹配条件。
关键要点
- 过滤器名称:check_password
- 参数:$check(布尔值,表示密码是否匹配)、$password(字符串,明文密码)、$hash(字符串,哈希密码)、$user_id(字符串或整数,可选用户ID)
- 返回值:应用过滤器后的 $check 值
- 相关函数:wp_check_password() 使用此过滤器进行密码验证
- 版本变化:WordPress 6.8.0 默认使用 bcrypt 哈希,旧密码可能仍使用 phpass 或 md5
原文内容
Filters whether the plaintext password matches the hashed password.
Parameters
$checkbool-
Whether the passwords match.
$passwordstring-
The plaintext password.
$hashstring-
The hashed password.
$user_idstring|int-
Optional ID of a user associated with the password.
Can be empty.
Source
return apply_filters( 'check_password', $check, $password, $hash, $user_id );