pre_user_{$field}
云策文档标注
概述
pre_user_{$field} 是一个动态 Hook,用于在数据库上下文中过滤用户字段的值。它允许开发者在用户字段值被处理前进行修改或验证。
关键要点
- 这是一个动态 Hook,$field 部分指代用户字段名,如 user_login、user_email 或 first_name。
- 主要用于在数据库操作中过滤用户字段的值,确保数据的一致性和安全性。
- 通过 apply_filters 调用,参数 $value 是待过滤的用户字段值。
注意事项
- Hook 名称是动态的,使用时需根据具体字段名替换 $field。
- 与 sanitize_user_field() 函数相关,常用于用户字段的清理和验证。
- 自 WordPress 2.9.0 版本引入,确保兼容性时需注意版本要求。
原文内容
Filters the value of a user field in the ‘db’ context.
Description
The dynamic portion of the hook name, $field, refers to the prefixed user field being filtered, such as ‘user_login’, ‘user_email’, ‘first_name’, etc.
Parameters
$valuemixed-
Value of the prefixed user field.
Source
$value = apply_filters( "pre_user_{$field}", $value );
Changelog
| Version | Description |
|---|---|
| 2.9.0 | Introduced. |