WordPress 为用户预设默认的后台配色方案

WordPress 3.8采用了全新的后台UI,默认自带了 8 种配色方案,如果你想为其他用户预设默认的后台配色方案,可以将下面的代码添加到主题的 functions.php :

//为新用户预设默认的后台配色方案
function set_default_admin_color($user_id) {
	$args = array(
		'ID' => $user_id,
		'admin_color' => 'sunrise'
	);
	wp_update_user( $args );
}
add_action('user_register', 'set_default_admin_color');

以上代码的第 4 行,设置的是 sunrise 这种配色方案,新用户注册和登录后台后,默认就会为 sunrise 配色。你可以自己修改为其他方案。

当然,用户自己还可以在“我的个人资料”中选择其他配色方案。如果你要禁止他们选择,可以将下面的代码添加到主题的 functions.php:

//对非管理员移除配色方案设置选项
if ( !current_user_can('manage_options') )
remove_action( 'admin_color_scheme_picker', 'admin_color_scheme_picker' );

这样,非管理员角色的新用户在“我的个人资料”就看不到配色方案的设置选项了。

如果你觉得默认的 8 种颜色无法满足你,你可以为 WordPress 3.8 添加更多后台界面配色方案

参考资料:http://www.wpbeginner.com/wp-tutorials/how-to-set-default-admin-color-scheme-for-new-users-in-wordpress/

来源:

https://www.wpdaxue.com/set-default-admin-color-scheme-for-new-users.html

微信公众号
手机浏览(小程序)

Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(): Failed to enable crypto in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_32405.jpg): failed to open stream: operation failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57
0
分享到:
没有账号? 忘记密码?