Function: update_user_option

update_user_option( integer $user_id, string $option_name, mixed $newvalue, boolean $global )

Update user option with global blog capability.

Shortcut: uuo

You can use above key combination to trigger the associated snippet for this function in the WordPress Snippets for Visual Studio Code extension. You can also use this shortcut to search for this function on this website.

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.

Parameters

Name Type(s) Default Value Description
$user_id integer

User ID.

$option_name string

User option name.

$newvalue mixed

User option value.

$global boolean false

Optional. Whether option name is global or blog specific. Default false (blog specific).

Returns

integer | boolean

User meta ID if the option didn't exist, true on successful update, false on failure.

WordPress Developer Newsletter

Stay informed of new chapter releases, important WordPress API updates and more.