Function: update_user_option

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

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.

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 on top of the latest WordPress API changes, developer tool updates, security alerts and more.