update_user_option()
update_user_option( int $user_id, string $option_name, …
update_user_option( int $user_id, string $option_name, mixed $newvalue, bool $global = false )
使用全局博客功能更新用户选项。
Update user option with global blog capability.
使用全局博客功能更新用户选项。
Update user option with global blog capability.
目录锚点:#说明#参数#源码#笔记
说明(Description)
用户选项和用户元数据一样,只是它们支持全局博客选项。如果’global’参数为false(默认为false),它将在选项名称前面加上WordPress表前缀。如果$newvalue为空,则删除用户选项。
参数(Parameters)
| 参数 | 类型 | 说明 |
|---|---|---|
| $user_id | (int) | 用户ID。 |
| $option_name | (string) | 用户选项名称。 |
| $newvalue | (mixed) | 用户选项值。 |
| $global | (bool) | 选项名称是全局的还是特定于博客的。默认为false(特定于博客)。 |
源码(Source)
/**
* Update user option with global blog capability.
*
* User options are just like user metadata except that they have support for
* global blog options. If the 'global' parameter is false, which it is by default
* it will prepend the WordPress table prefix to the option name.
*
* Deletes the user option if $newvalue is empty.
*
* @since 2.0.0
*
* @global wpdb $wpdb WordPress database object for queries.
*
* @param int $user_id User ID.
* @param string $option_name User option name.
* @param mixed $newvalue User option value.
* @param bool $global Optional. Whether option name is global or blog specific.
* Default false (blog specific).
* @return int|bool User meta ID if the option didn't exist, true on successful update,
* false on failure.
*/
function update_user_option( $user_id, $option_name, $newvalue, $global = false ) {
global $wpdb;
if ( !$global )
$option_name = $wpdb->get_blog_prefix() . $option_name;
return update_user_meta( $user_id, $option_name, $newvalue );
}| 更新版本 | 源码位置 | 使用 | 被使用 |
|---|---|---|---|
| 2.0.0 | wp-includes/user.php | 4 | 9 |
笔记(Notes)
基本示例
类别:WordPress 函数手册、
本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。





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