5

I am trying to change the WordPress Admin panel look and feel for depending upon the different role types that are in WordPress. How can create/assign different themes for each role i.e.

  • Editor > Admin Panel Theme 1
  • Author > Admin Panel Theme 2
  • Contributor > Admin Panel Theme 3
  • Subscriber > Admin Panel Theme 4

or even for the website Administrator also.

what i am looking for is to change the WordPress admin panel html structure/layout, User Interface.

Are there any hooks or action available, please guide.

Regards,

4

Here's a great codex article on the topic of creating administration theme: http://codex.wordpress.org/Creating_Admin_Themes

And back to your question, you will want to load different stylesheets for different user roles, so you have to check who the current user is. Pay attention, the check is done using current_user_can() function and checking for administrator is not being done via is_admin() ( that's a check if you script is being loaded on administration side of your web, not for administrator ).

Slightly modified 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');

Also, see Roles and capabilities page for getting an idea on how you can differentiate user roles.

Cheers!

  • thanks david, one more question can i change the html structure/layout of the standard WordPress admin panel to a total new layout. – FaisalShehzad Sep 25 '14 at 8:25
  • There no easy solution for this, to my knowledge. The whole administration is quite complex and if your changes are not possible via CSS or JS, you have to inspect each particular page and functions which are behind it. But still, it's quite complex bit of code and a lot of things is simply hardcoded. Eg: see the dashboard source code: github.com/WordPress/WordPress/blob/master/wp-admin/index.php – david.binda Sep 25 '14 at 9:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.