Skip to content

Instantly share code, notes, and snippets.

@jancbeck
Last active January 15, 2022 19:34
Show Gist options
  • Save jancbeck/3178689 to your computer and use it in GitHub Desktop.
Save jancbeck/3178689 to your computer and use it in GitHub Desktop.
WordPress: Add user role class to body tag
<?php
// Add role class to body
function add_role_to_body($classes) {
foreach (wp_get_current_user()->roles as $user_role) {
$classes[] = 'role-'. $user_role;
}
return $classes;
});
add_filter('body_class','add_role_to_body');
add_filter('admin_body_class', 'add_role_to_body');
?>
@posgross
Copy link

HELLO
I am beginner! Pltease help!

I need the snippet, which will hide the button ADD LISTING for couple roles

Please help I don't understand

I download and install "Code Snippets"

For test I take the code from the first messages of this discussion

http://joxi.ru/Y2Lw477tMb1Rvm

I need make 2 snippets for two different roles

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment