I am trying to do a #tribe_events_event_options{display:none;} for all the author users on my site. I don't want them to be able to set an event to featured, and I thought the simplest way was to not display the box.

Is there an easy way to target user groups for custom css? I've made a author.css file in the child theme folder.

I found this post, but It did not do it for me. Custom CSS In Admin Only For Certain Roles

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

Writing css like: example

.role-editor #main-header {display:none;}

But the css is not affected. Am I missing something?

Thanks in advance!

  • Is it in the frontend or in wp-admin area?
    – mukto90
    Commented May 1, 2018 at 15:38
  • Have you tried to !important to the css? .role-editor #main-header {display:none !important ;}
    – BenB
    Commented May 1, 2018 at 17:40
  • @mukto90 it's in the wp-admin area. I am trying to disable the "feature event" option in the The Events Calendar for authors as the editor should be the only one to make events featured. BenB I have tried "!important". The css seem to work for frontend, but not for the admin panel/events in my case.
    – Blomshit
    Commented May 2, 2018 at 16:29

1 Answer 1


Your code seems to be correct maybe your selector is wrong? can you post the body html of your page that is outputed?

  • The code didn't work for me for some reason. I changed it to: add_filter( 'body_class', function( $classes ) { if( is_user_logged_in() ) { $classes = array_merge( (array) $classes, array_map( function( $class ) { return 'role-' . $class; // Here we prepend the 'role-' string }, (array) wp_get_current_user()->roles ) ); } return $classes; } ); That helped, and now I can target user roles, but not admin panel
    – Blomshit
    Commented May 2, 2018 at 16:34
  • @Blomshit the body_class filter only applies to front end, you have to use admin_body_class to target the backend. If you do a var_dump($classes) what is outputted to the screen?
    – Orlando P.
    Commented May 2, 2018 at 19:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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