Opens in a new tab
Turquoise abstract wavy W logo on a black background
Turquoise abstract wavy W logo on a black background
White WP PowerSuite logo on a black background
White WP PowerSuite logo on a black background
[wpps_ai_summarize]
On This Page
Last updated: 08/09/2026

Username Body Class

Body classes for logged-in username and user ID—useful for theme tweaks and personalization. Privacy note: the username and ID appear in the page HTML source for that logged-in user.

Overview

Target the current logged-in user in your WordPress styling without writing a separate PHP function to identify the account. Username Body Class adds a username-based class and a numeric user-ID class to the page body, giving developers predictable selectors for individual-user presentation.

The classes are available on both the frontend and in wp-admin. Guests receive neither class, and there are no settings to configure. Username Body Class is a Free module that supplies styling hooks, not a permissions system or a visual design editor.

Solid black square
Solid black square
Who is this for?
  • Developers building account-specific WordPress interfaces
  • Agencies adding small presentation changes for individual client accounts
  • Teams that need consistent user selectors on the frontend and in wp-admin
  • Sites combining individual-user styling with broader role-based presentation

Features

Username-Based Body Class
Add a class in the format user-{sanitized-login} for the current logged-in account.
Numeric User-ID Class
Add user-id-{ID} alongside the username class so styling can target a specific account by its ID.
Frontend and Dashboard Coverage
Make the same user identification available through WordPress frontend and admin body classes.
Logged-In Users Only
Leave guest page views without username or user-ID classes.
No Configuration Required
Enable the module to add the selectors automatically. Your stylesheet determines what they change visually.

Add User-Specific CSS Hooks Without Custom PHP

A WordPress site can need a small presentation difference for one particular account without needing a completely different theme or dashboard. A client reviewer may need a prominent project notice, or a developer may want a visual marker that makes an individual test account easy to recognize. The first requirement is a reliable way to identify that account in the page markup. Username Body Class supplies that identification on the body element instead of requiring a custom user-detection function.
For a logged-in account named project_editor with ID 42, the resulting classes follow the formats user-project_editor and user-id-42. A stylesheet can then target either selector together with the specific page element it should affect. The module does not inject a banner, recolor a dashboard, or hide controls by itself. It provides the connection between the active WordPress account and CSS rules you deliberately create for that account.

Choose a Username or User-ID Selector

The two classes give developers different ways to express the same individual-user target. A username-based selector can be easier to recognize when reading a stylesheet, particularly on a small project with a handful of known accounts. The numeric selector is useful when you want the rule to refer to the account ID rather than its login spelling. Both are added together, so you do not need to choose a mode or maintain a list of users in module settings.
The name comes from the WordPress login, not the display name or email address. That distinction matters when an author changes the name shown on articles: the module is not designed to follow that public byline. Conversely, changing the actual login name changes the username-derived selector. On sites using Username Changer, review username-based CSS after a rename or use the ID-based selector for rules that should remain tied to the same account.

Use the Same Approach on the Frontend and in wp-admin

User-specific presentation can be useful in more than one part of WordPress. A frontend account area may need a notice for a particular reviewer, while an administrative interface may need a visual cue for a known editor or testing account. Username Body Class works with both WordPress body-class mechanisms, giving you a consistent naming pattern without creating two separate user-identification snippets.
The surrounding styles still need to suit the area where they run. A selector written for a frontend component does not automatically style an equivalent dashboard component, and the module does not load your custom stylesheet for you. Its job is to add the account classes where WordPress produces the relevant body markup. You retain control over the CSS, the elements it targets, and whether a presentation change belongs on the frontend, in wp-admin, or in both places.

Combine Individual and Role-Based Presentation

An individual account rule is useful for an exception, but it is not always the right foundation for an entire team. If every editor should receive the same visual treatment, maintaining separate selectors for each editor would create unnecessary work as staff join or leave. User Role Body Class adds role-based selectors for that broader requirement and can work alongside Username Body Class.
For example, a general role selector can establish the appearance used by the editorial team, while a user-ID selector adds a specific reminder for one review account. If a class should apply to the whole public website regardless of who is signed in, Custom Body Class handles that different scope. Choosing the appropriate level keeps the stylesheet easier to maintain instead of using individual usernames for every site-wide or role-wide decision.

Keep Styling Separate From Access Control

A body class changes what your CSS can target; it does not change what the WordPress account is allowed to do. Hiding a button or section with an account-specific selector does not remove the underlying data, deny a direct request, or replace a capability check. Username Body Class is therefore suited to visual distinctions and interface adjustments, not protecting private content or preventing an administrator from reaching a sensitive action.
The account identifier also becomes visible in the HTML sent to that viewer. The module adds no such classes for guests, but a cache that incorrectly shares logged-in HTML could expose one user's login and ID in another visitor's response. Keep personalized page caching separated appropriately and consider whether publishing these identifiers in the current user's markup fits the project. The module is an explicit styling convenience, not a username-obfuscation feature.

Use Cases

  • Client Review Accounts
    Target an existing review notice or visual indicator for one client account without applying the same treatment to every administrator.
  • Individual Dashboard Adjustments
    Apply deliberate presentation changes to a particular logged-in user's wp-admin interface.
  • Frontend Account Styling
    Use a user-ID selector for a specific account-area component that already exists in your theme or custom layout.
  • Role-Based Designs With Exceptions
    Combine shared role styling with a narrow individual-user rule when one account needs different presentation.

Frequently Asked Questions

Related Modules

Selected custom menu links open in a new tab with safe rel attributes.
Disabled
Turn off drag-and-drop for the roles you choose as a gentle nudge against moving images or text off the page—not foolproof, but...
Disabled
Duplicate a menu and all its items in one click from the Menus screen.
Disabled
Add custom fields to posts and taxonomy terms, then display them anywhere with blocks, shortcodes, or page builders. For site-wide settings pages,...
Disabled
Share buttons for major networks and email—floating bars, inline before/after content, or shortcode—without third-party tracking widgets.
Disabled
Custom excerpt word counts and read-more wording for archive and blog layouts.
Disabled
Organize the Media Library with a folder tree sidebar, drag-and-drop assignment, and settings in a modal.
Disabled
Auto-unpublish posts after a date you set—set-and-forget for time-limited offers and listings.
Disabled
Dashboard widget with content and user counts, including drafts, published items, and custom types.
Disabled
Generate many similar pages from a CSV template—great for local landing pages and repeatable layouts.
Disabled