Function: set_user_setting

set_user_setting( string $name, string $value )

Add or update user interface setting.

Both $name and $value can contain only ASCII letters, numbers and underscores.

This function has to be used before any output has started as it calls setcookie().


Name Type(s) Default Value Description
$name string

The name of the setting.

$value string

The value for the setting.


boolean | null

True if set successfully, false if not. Null if the current user can't be established.

WordPress Developer Newsletter

Stay on top of the latest WordPress API changes, developer tool updates, security alerts and more.