On This Page
User Role Body Class
Overview
User Role Body Class enriches WordPress’s body_class() output with predictable tokens for every role assigned to the current account: role-administrator, role-editor, role-subscriber, and so on. Users carrying multiple roles receive multiple classes simultaneously. Anonymous visitors gain role-guest on the public site so you can style promos for guests—or omit them for logged-in members—without scattering is_user_logged_in() checks across PHP templates.
In wp-admin, logged-in users also receive the same role-based classes on body, which helps tailor dashboard density or color for support staff vs subscribers when membership plugins expose custom roles.

Features
Multi-Role Coverage
Guest Signal
Admin Parity
Filter-Based
How It Works
Enable the Module
Create Test Accounts
Inspect Body Markup
Author CSS Safely
Combine with Role Plugins

Installation & Activation
Install WP PowerSuite
Enable User Role Body Class
Theme body_class Required
Privacy Review

Use Cases
- ModalControlHide aggressive upsell modals for any logged-in role (non-guest).
- AdminTableExpandExpand wp-admin tables only for role-shop_manager in WooCommerce stacks.
- BetaToggleBeta UI toggles for role-beta_tester without feature flag SaaS costs.
Frequently Asked Questions
Can I combine with Username Body Class?
Yes—roles and login slugs are orthogonal hooks; use both when personalization demands specificity.
Does role-guest appear in admin?
Typically admin body targets logged-in users; guests rarely load full wp-admin chrome—confirm behavior if custom login screens exist.
What about Super Admin on multisite?
Capabilities map to roles per site context—test network admin vs site admin separately.
Custom roles from PMPro or MemberPress?
Plugins register slugs such as role-customer—verify underscores vs hyphens match sanitizer output.
Caching logged-in pages?
If Vary: Cookie headers absent, role-specific CSS may leak across users—fix at CDN layer.
Troubleshooting
- Expected role class missingRe-check Users → profile roles; some plugins mutate roles after login—log out and in again.
- Classes appear but CSS ignoredSpecificity wars with utility frameworks—chain selectors or use !important sparingly.
- Too many classes on bodyAccounts with rare multi-role combos may need documentation for QA—trim excessive role assignments.
