_get_additional_user_keys()
云策文档标注
概述
_get_additional_user_keys() 函数返回一个用户元键列表,这些键可能在 wp_update_user() 中被填充。该列表基于用户元数据中存在的键动态生成。
关键要点
- 函数返回一个字符串数组,包含用户元键,用于 wp_update_user() 操作。
- 列表包括预设键(如 first_name、last_name)和通过 wp_get_user_contact_methods() 动态添加的联系方式键。
- 参数 $user 是必需的 WP_User 实例,用于确定联系方式键。
- 函数自 WordPress 3.3.0 版本引入。
代码示例
function _get_additional_user_keys( $user ) {
$keys = array( 'first_name', 'last_name', 'nickname', 'description', 'rich_editing', 'syntax_highlighting', 'comment_shortcuts', 'admin_color', 'use_ssl', 'show_admin_bar_front', 'locale' );
return array_merge( $keys, array_keys( wp_get_user_contact_methods( $user ) ) );
}
原文内容
Returns a list of meta keys to be (maybe) populated in wp_update_user() .
Description
The list of keys returned via this function are dependent on the presence of those keys in the user meta data to be set.
Parameters
Source
function _get_additional_user_keys( $user ) {
$keys = array( 'first_name', 'last_name', 'nickname', 'description', 'rich_editing', 'syntax_highlighting', 'comment_shortcuts', 'admin_color', 'use_ssl', 'show_admin_bar_front', 'locale' );
return array_merge( $keys, array_keys( wp_get_user_contact_methods( $user ) ) );
}
Changelog
| Version | Description |
|---|---|
| 3.3.0 | Introduced. |