WordPress开发者和主题制作者的搜索引擎



set_user_setting ›

Since2.8.0
已弃用n/a
set_user_setting ( $name, $value )
参数: (2)
  • (string) $name The name of the setting.
    Required: Yes
  • (string) $value The value for the setting.
    Required: Yes
返回:
  • (bool|null) True if set successfully, false if not. Null if the current user can't be established.
定义在:
文档:

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().



源码

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 );
}