下面是一篇关于创建管理主题的很棒的codex文章:http://codex.wordpress.org/Creating_Admin_Themes
回到您的问题,您需要为不同的用户角色加载不同的样式表,因此您必须检查当前用户是谁。注意,检查是使用current_user_can() 未通过执行功能和检查管理员is_admin() (这是检查脚本是否加载到web的管理端,而不是管理员)。
略微修改first code example of a codex
<?php
function my_admin_theme_style() {
if ( current_user_can( \'manage_options\' ) ) { //means it is an administrator
$style = \'my-admin-theme-administrator.css\';
} else if ( current_user_can( \'edit_others_posts\' ) ) { //editor
$style = \'my-admin-theme-editor.css\';
} else if ( current_user_can( \'edit_published_posts\' ) ) { //author
$style = \'my-admin-theme-author.css\';
} else if ( current_user_can( \'edit_posts\' ) ) { //contributor
$style = \'my-admin-theme-contributor.css\';
} else { //anyone else - means subscriber
$style = \'my-admin-theme-subscriber.css\';
}
wp_enqueue_style(\'my-admin-theme\', plugins_url($style, __FILE__));
}
add_action(\'admin_enqueue_scripts\', \'my_admin_theme_style\');
function my_admin_theme_login_style() {
//we can\'t differentiate unlogged users theme so we are falling back to subscriber
$style = \'my-admin-theme-subscriber.css\';
wp_enqueue_style(\'my-admin-theme\', plugins_url($style, __FILE__));
}
add_action(\'login_enqueue_scripts\', \'my_admin_theme_login_style\');
此外,请参见
Roles and capabilities page 了解如何区分用户角色。
干杯