0

How would I apply some front end CSS to a specific user role or roles?

1
  • 1
    See this Q&A for more information. Commented Oct 4, 2015 at 15:12

1 Answer 1

3

If you're looking for a way to add the roles into the body class, like here:

<body class=" ... role-administrator role-jedi role-knight ... "> 

then you could try the following:

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.