This works for the admin backend; I needed to restructure the filter to be able to add a priority:
function add_admin_body_class($classes) {
$user = wp_get_current_user();
foreach ($user->roles as $user_role) {
$classes .= " role-{$user_role}";
}
return $classes;
}
add_filter("admin_body_class", "add_admin_body_class", 9999);
Related Posts:
- How to auto-translate custom user roles?
- Add class to woocommerce checkout body based on filter [closed]
- De-bloating the page classes
- How to allow users to view pending posts of a specific custom post type?
- upload_files cap to not loggen in users – add_cap to not logged in users
- Add content as soon starts
- Why current_user_can(‘edit_comment’) always true?
- Removing menus from users other than the administrator
- How to filter reading/visibility posts based on role?
- mu-plugins body_class filter not working
- Testing requested query in pre_get_posts
- Filter and validate user role in registration
- Filter dashboard custom post listing by user
- Block Gutenberg Editor manually by User Roles with a Filter with code
- Not able to change wp_title using add_filter
- How to hook a filter to catch get_post_meta when alternate a custom field output?
- Changing JPEG compression depending on image size
- How to add headers to outgoing email?
- Advanced Custom Fields and Yoast SEO keyword analysis [closed]
- Insert Custom HTML After Shortcode
- Is there a way to add another row to the tinyMCE kitchen sink toggle?
- Remove description from on Home
- add_filter to youtube embeds?
- How can I detect if a user changes their password?
- SSL certificate for the host could not be verified
- Store source permalink on XMLRPC calls
- How to limit the pages displayed for choosing parent page on page attribute’s menu?
- Moving sharedaddy buttons (in Jetpack) to the top of a post?
- WordPress RSS feed – filter RSS content by custom field value
- What is the filter hook for custom fields content?
- Filter keywords from search query
- changing variable through filters or action hooks
- filter the_title problem in nav
- Changing Gutenberg / WP block editor width only on pages, not posts or other taxonomies
- How to replace any occurence of Gravatars with a local placeholder image?
- Ignore dots when searching in the media library?
- How to change the blog title with add_filter? details below
- How To Get User Data in Callback Function for pre_user_nicename?
- What’s the best way to split admin-only functionality in the theme’s functions.php file?
- the_content filter – checking the post
- Which built-in WordPress files are safe to edit?
- Why won’t my preg_replace work with content_save_pre?
- How do I target a single page to modify the comment form of only that page?
- How Does comment_author Filter Work?
- Add ‘data-text’ attribute to TagCloud HTML
- How to removes all instances of thumbnails displayed in my theme?
- Contact Form 7 filter similar to preprocess_comment [closed]
- Walker_Nav_Menu doesn’t work in wp_page_menu_args filter
- get_posts() and filters
- Adding TinyMCE buttons without removing plugin buttons?
- Cannot change the definition of AUTOMATIC_UPDATER_DISABLED
- How do I add a checkmark to my-sites save settings hook
- How to customize the “Insert/edit link” popup box?
- How to filter backend post list showing only posts having a shortcode
- Add Lightbox To WordPress Native Gallery
- How do I override the_excerpt so that it will display full content?
- Get current user data
- get_post() containing gallery is outputting an unmatched closing div at the end of the content
- Trouble using remove_filter to override function in parent theme
- How to add attributes to WordPress Admin Sub Menu List Items
- How do I hook my function to run only after submitting login form
- Prepending character(s) to a custom tag title?
- How to write a filter to remove a form field (WordPress) [closed]
- Why doesn’t this function work when I know that the IP Address is “true”?
- Modify existing plugin function with add_filter
- include specific Pages to wp_list_pages with filter
- Map plugin with proximity search compatible with Buddypress
- Create a pre-filtered version of the Media Library
- Get_template_part inside filter?
- How to filter Sidebar Content
- Removing URL and adding container around image in the featured image metabox
- Email Obfuscation: Is antispambot() Acceptable? [closed]
- How would I use a filter to remove header banner on certain post types
- What are the steps + prerequisites for using an add_filter?
- an action hook when a post reaches a certain number of views
- WordPress overwrites UNC
- Excluding posts by meta, and also keeping posts without the meta
- Change tags url to search different site
- How can I tranlslate post date in italian?
- Having wp-admin on different domain
- Use a functions in functions.php to remove a string for template theme
- oembed_dataparse filter not running at all for standard YouTube embed
- Action for opening attachment or manipulating all attachment links
- Filter wp_mail based on content type
- Add filter conditionally to a page
- Remove the post_content search from WHERE clause (and CONCAT sql function)
- Post filter Month dropdown at front-end like wordpress backend
- shortcode function outputs multiple anchor tags
- WP Dashboard -> Posts-> Filter by Category -> Form Method Change : Which Hook
- Show child theme for users on specific IP
- Remove action added from class
- wp.getPosts with status = ‘trash’ using node.js
- Is there a way to overwrite a filter used in canonical.php?
- Adding an orderby filter, casting postmeta with multiple keys
- post->post_content filter
- How to change this WP logo and posts url in block editor?
- Replacing text using add_filter
- Background color and background image below element in Contact Form 7 – error tip [closed]
- Change password reqts with NO plugin without breaking resetpass link?
- How can I conditionally add the filter option_home?