update_user_meta()
update_user_meta( int $user_id, string $meta_key, mixed…
update_user_meta( int $user_id, string $meta_key, mixed $meta_value, mixed $prev_value = ” )
根据用户ID更新用户元字段。
Update user meta field based on user ID.
根据用户ID更新用户元字段。
Update user meta field based on user ID.
目录锚点:#说明#参数#源码#笔记
说明(Description)
使用$prev_value参数区分具有相同密钥和用户ID的元字段。如果用户的元字段不存在,则将添加该字段。
参数(Parameters)
| 参数 | 类型 | 说明 |
|---|---|---|
| $user_id | (int) | 用户ID。 |
| $meta_key | (string) | 元数据键。 |
| $meta_value | (mixed) | 元数据值。 |
| $prev_value | (mixed) | 删除之前要检查的值。 |
源码(Source)
/**
* Update user meta field based on user ID.
*
* Use the $prev_value parameter to differentiate between meta fields with the
* same key and user ID.
*
* If the meta field for the user does not exist, it will be added.
*
* @since 3.0.0
* @link https://codex.wordpress.org/Function_Reference/update_user_meta
*
* @param int $user_id User ID.
* @param string $meta_key Metadata key.
* @param mixed $meta_value Metadata value.
* @param mixed $prev_value Optional. Previous value to check before removing.
* @return int|bool Meta ID if the key didn't exist, true on successful update, false on failure.
*/
function update_user_meta($user_id, $meta_key, $meta_value, $prev_value = '') {
return update_metadata('user', $user_id, $meta_key, $meta_value, $prev_value);
}| 更新版本 | 源码位置 | 使用 | 被使用 |
|---|---|---|---|
| 3.0.0 | wp-includes/user.php | 13 | 7 |
笔记(Notes)
如何检查错误
类别:WordPress 函数手册、
本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。





还没有任何评论,赶紧来占个楼吧!