Adds or updates user interface setting.
Description
Both $name
and $value
can contain only ASCII letters, numbers, hyphens, and underscores.
This function has to be used before any output has started as it calls setcookie()
.
Parameters
$name
stringrequired- The name of the setting.
$value
stringrequired- The value for the setting.
Source
function set_user_setting( $name, $value ) {
if ( headers_sent() ) {
return false;
}
$all_user_settings = get_all_user_settings();
$all_user_settings[ $name ] = $value;
return wp_set_all_user_settings( $all_user_settings );
}
Changelog
Version | Description |
---|---|
2.8.0 | Introduced. |
Override the user setting to always collapse the admin menu for the current user: