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. ???

1 Answer
1

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

Leave a Reply

Your email address will not be published. Required fields are marked *