Function: set_user_setting

set_user_setting( string $name, string $value )

Add or update user interface setting.

Shortcut: sus

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.

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 informed of new chapter releases, important WordPress API updates and more.