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;
} );
Related Posts:
- If post by specific role different css to everyone
- Enable specific CSS Code for Visitors and specific Roles
- Change color of audio player depending on user role
- How to insert the current user’s role into the body class in the admin backend
- check the first login for specific roles
- Gutenberg Editor: display error with a combination of transform and background-attachment:fixed
- How to include backend buttons css on frontend?
- How to use WordPress 3.8 back-end CSS in front-end?
- What’s the difference between SCSS and Sass?
- What is a user agent stylesheet?
- CSS opacity only to background color, not the text on it?
- How do I center floated elements?
- How to set up fixed width for
? - Make div scrollable
- How do I center an h1 in the body
- Can you set a border opacity in CSS?
- Any way to limit border length?
- Why “Inline-block” doesn’t work properly in this CSS?
- How to fade an image with CSS without opacity?
- Flushing footer to bottom of the page, twitter bootstrap
- CSS transition fade in
- Is it possible to define constants in CSS?
- Responsive media query not working in Google Chrome
- Contain an image within a div?
- Failed to decode downloaded font
- How to make fixed header table inside scrollable div?
- CSS fill remaining width
- TinyMCE: adding CSS to format dropdown
- How to conditionally enqueue a stylesheet only for a certain page(s)?
- Is there a quick way to remove inline css from all posts?
- How to remove CSS file in the header using WordPress functions?
- Get list of registered or enqued styles? looking for filters or actions
- wp_get_archives() – Get CSS selector for current month
- Do I only need to import style.css for a child theme?
- Disable child theme css on certain pages
- How to load a css file in one page only?
- How to add custom fonts in WordPress site
- Handling URLs in WordPress application
- Extending content width with twentyfourteen theme
- Override load-styles.php with admin screen css
- CSS file not registering through add_action
- Custom Admin CSS styles to style media uploader?
- getting url in wp_enqueue_style
- Gutenberg Additional CSS Class without modifying theme?
- Eliminate render-blocking JavaScript and CSS in above-the-fold content
- Unable to load CSS file (HTTP 403)
- Dynamic sidebar nav with current page highlighting
- how to setup content on a static frontpage with css and xhtml
- wp_enqueue_style – CSS Not loading – ERR_TOO_MANY_REDIRECTS [closed]
- Help with child theme enqueuing additional css files
- Why does my caroussel gallery do this in responsive? [CSS] [closed]
- Website CSS not loading [closed]
- Custom styles dropdown in TinyMCE editor – not working with headings
- Load CSS in footer, like your can with JS?
- Correct Way To Make Changes To A WordPress Theme
- Move Sidebar from Above Content To Below When Responsive [closed]
- wordpress css file
- Implementing a simple slider in code?
- CSS – Initial HTML Margin Issue On WordPress Site
- Cannot set property ‘className’ of null at setThemeFromCookie
- Target h1 on single post page [closed]
- Can not find css directory in header
- custom header navigation has odd spacing [closed]
- jQuery UI Theme that aligns perfectly with the admin UI
- Error in node.js webpack-cli failed to load config, typeError: ManifestPlugin is not a constructor
- dynamic css file for admin / backend and get_option results in Uncaught Error: Call to undefined function get_option()
- How can I force Dynamic CSS via ACF values to update on page load?
- WordPress backend is loading without style
- Append style tag in head while shortcode runs
- Add a unique body class for every admin page (including trash)
- Why would a theme writer put their CSS in one long string? [closed]
- Show product information on right side [closed]
- How to integrate Bootstrap Grid System in WordPress
- Show/Hide Div for Login Mask
- Target admin page body via CSS class
- Hide Overflow on a Specific WordPress Template
- Google Chrome CSS issues [closed]
- ACF Gut block broke wordpress default style?
- Scroll code block instead of wrapping text
- Divi CSS Flex/Margin Error
- How to enqueue stylesheets in child-theme functions.php?
- Change class value using CSS
- Dequeue CSS of the Parent Theme
- How to make video responsive in full height on mobile?
- div:before appearing in front of the block
- How to replace wordpress css or js file with external file?
- Unable to properly load WordPress Admin page
- Change style of Twenty Seventeen child theme
- Why is css not applied on paginated query?
- Disable CSS specific page
- Editing anchor style in main navigation bar
- My contact form is not being responsive
- I can’t change the background color of a specific page
- how to make social media buttons start only from under a photo/post?
- What can cause JavaScript and CSS files to be minified?
- 100% Width Footer – Custom Child Theme
- Twenty thirteen theme change the height of menu sub items
- Bullet List Indentation not showing up in the wordpress
- I want to Hide CSS ID for specific user roles
- Busting Browser Cache when updating stylesheet of WordPress website