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' );
Related Posts:
- Remove admin bar for subscribers
- Editor role cannot save custom theme options
- “wp_enqueue_style();” don’t load new edited style
- functions.php not adding css to website?
- if file_exists not working with wp_enqueue_style
- Using PHP to toggle stylesheet and header image, set in cookie
- Archive dropdown styling not applied
- Different background-image by category
- Add a Different CSS Class Into The Body Tag of Different WP Pages
- Put CSS inside a PHP file and include it the right way
- How Display Posts on category
- Slider loading issue
- How to give new users two specific user role options upon WordPress user registration
- Parent theme CSS overriding child CSS rules
- How to style options page in dashboard?
- Theme Options Page – User Updates Logo
- Dynamic Stylesheet loads but doesn’t finish
- How to add date to navigation bar
- Incorrect MIME type for assets with Valet
- Customize position of social icons in upme plugin [closed]
- Css loads very slow [closed]
- How create a Shortcode with hover and complex options
- WordPress Multiple Navigation bars
- Auto 301 to full post permalink? (using : /archive/%post_id% to %post_name% )
- Whats the proper way to use a php stylesheet in a wordpress theme? [duplicate]
- How do I add a custom css to all posts without affecting homepage css? [closed]
- proper way to add css using functions.php?
- Automatically set all tags to have a height of 0 if there is no content inside the tag [closed]
- RTL Stylesheet Confusion with WordPress
- Correct way to enqueue page specific CSS file
- Wrapping a Sidebar within
- How to make container class in PHP
- PHP in CSS file?
- Clickable image link sends people to wrong URL
- Last class on last headline?
- Creating a blog on my companies new website using WordPress but I have sidebar issues
- How to remove sidebar primary widget on Mobile on category page [closed]
- How to Change CSS Colors from Custom Plugin Settings Page
- Can I set up a hover animation in CSS depending on a PHP conditional?
- Get ACF options field in PHP acting as CSS
- Array to string conversion error in PHP 7.2 when returning user role as class
- Problem with adding custom CSS class to image in ACF Photo Gallery plugin [closed]
- Noindex subscriber author page
- Link to page with posts of specific type
- Conditionally load class in the comment section of the post page
- Assign Custom classes to every Excerpt
- How can I call a specific file (via php) by referencing the logged-in username?
- CSS images don’t show up with bloginfo
- Adding a navigation page state to individual blog and portfolio pages
- Using theme options to change a border-radius value
- Inline CSS header style priority function.php Child (no enqueing I think)
- Displaying images outside the content
- Execute PHP code only with specific user role
- how to changes mobile menu toggle breakpoint in WordPress
- Applying css in functions.php
- PHP function for horizontal Woocommerce thumbnails and badges
- oceanwp+woo mobile cart sidebar text
- My top header looks different on single pages but is fine on the home page
- Using php code inside style tag
- dynamic php menu with hidden sub-categories only showing when the category name is clicked
- How to hide a div section when user is logged in, in single product woocommerce
- Drop down question
- Can’t display anything through homepage text editor
- How to print all the inline styles in the WP_Styles instance together with their keys?
- The style.php file inside theme-engine folder has other content on FTP
- How to let mobile navigation menu close when link is clicked?
- how to add functions to my function.php using a child theme?
- Replace header with large image on home page only, using Genesis child theme
- Site title not showing. Please help me
- Fix hover images blink
- Hot to edit WooCOmmerce dashboard?
- Blog Image and Title in Right Sidebar
- Add class for the_post_thumbnail_caption()
- Echo Option Value Based On WordPress User Role
- Target a specific container to style on WordPress storefront theme
- How to add Open/Close Toggle button into Twenty Fifteen theme for hiding left sidebar?
- Position a repeated article blocks
- Custom Theme, Editor won’t wrap text (i.e. change width)
- Click to expand menu
- Hide button based on PHP result
- Revision History for Entire WordPress Site
- Child theme not working properly
- WordPress – Image href for home menu nav not working
- WP_Nav Highlight Parent Issue
- Add CSS class to PHP Statement
- How to add margin underneath woocommerce total price amount -> productpages
- Forbid certain users to access a specific page
- Load slideshow.css file only if Slideshow is checked / on
- New to wordpress. Need Help with templates [closed]
- Child-theme suddenly stopped working [closed]
- Parse error: syntax error, unexpected ‘}’ in
- Sorting Problem
- Custom HTML/CSS Theme into WordPress – SEO considerations
- ‘This Field is Required.’ is Not Displaying on CF7 [closed]
- why css file not link?how to create permalink?
- Custom Admin Menu Report for Specific User ID
- Using Featured Image as Hero Background in Word Press
- Editing stylehseet url in head section of WordPress
- Hide ID for WordPress User Role Subscriber
- Hide or Show Read More Button by Content Area