an observation, it’s not one or two users, it’s user roles, like clients
Are you using default WordPress roles, e.g., Author, Editor, Contributor, and so on, or have you created custom roles via a plugin?
You can check for specific roles in the roles
property of the user object.
$user = wp_get_current_user();
if ( in_array( 'author', (array) $user->roles ) ) {
// Add your custom CSS for Authors here.
}
I thought in the form of CSS it would be easier.
I agree with the suggestion about displaying the widget conditionally. If you need to detect roles and add custom CSS accordingly it might not be any easier.
Or were you imagining to be able to hook into an existing CSS class, for example is-author
or something? If so, I don’t think that’s available by default unfortunately.
If you’re comfortable with developing WordPress sites, there are a lot of hooks related to sidebars and widgets. For example the widget_text hook, which allows you to filter the contents of text widgets.
Knowing exactly which widget you want to show and where, would help to narrow down the options.
-
This reply was modified 3 years, 7 months ago by
ramonopoly.