WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using plugins "Capability Manager Enhanced" and "Adminimize". Between these two I have been able to do much of what I want to do.

There are still some elements I need to hide and have been able to target them with css.

The problem is that these elements are hidden across all admin user levels.

Is there something built in that distinguishes the different role levels in the admin?

I would think the best way to do this would be to add a class to the body tag according to the role level at log-in -- such as "author" class if log-in role level is "author".

If this is the best way I wouldn't know how to write the code to do this. I assume it would be a php addition to function.php. ???

share|improve this question

The admin_body_class filter lets you add classes to the body tag.

This function will add all roles as classes in the form role-$role, for example role-administrator, to the body tag:

function wpa66834_role_admin_body_class( $classes ) {
    global $current_user;
    foreach( $current_user->roles as $role )
        $classes .= ' role-' . $role;
    return trim( $classes );
add_filter( 'admin_body_class', 'wpa66834_role_admin_body_class' );
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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