WordPress plugin to add user-related classes to the body tag. This can be enabled on the frontend and backend of the site.
The css classes allow you to easily customize styling by role or a specific user.
After activating the class on the body tag, it will be up to you to use css or javascript to customize the display.
enhanced-body-class-admin.css
Edit enhanced-body-class-admin.css
and add the following:
body.user-role-administrator { background-color: cyan; }
Refresh the page. You should now see a cyan background. You can now update the css to change the display of specific
page elements.
This plugin was developed to hide certain elements in a popular photo gallery from users with a specific role.
Create the theme file enhanced-body-class-admin.css
`
body.user-role-contributor #updategallery #gallerydiv { display: none; }
`
Create the theme file enhanced-body-class-admin.js
`
jQuery(document).ready(function($) {
$(‘body.user-role-contributor select#bulkaction option[value=”copy_to”]’).attr(‘disabled’, ‘disabled’);
});
`
This plugin was created by Noah J. Stewart in response to a specific problem. In January 2019,
Noah Stewart was contacted by his father Jim Stewart regarding a WordPress photo gallery plugin
that his astronomy club was using. They were having trouble customizing a few of the role-based
options in a popular gallery plugin. Like any good graphic artist, Jim was trying to improve
the interface for the site users. The simplest approach to the problem was to use css to
selectively hide certain elements, ie. invisible content users with the author role that
should be visible to users with the administrator role.