Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rajilesh/2618ee27cacc869cd3cf54680c7c7a75 to your computer and use it in GitHub Desktop.
Save rajilesh/2618ee27cacc869cd3cf54680c7c7a75 to your computer and use it in GitHub Desktop.
<?php
// Add role class to body
function jb_add_role_to_body($classes) {
if (is_user_logged_in()) {
foreach (wp_get_current_user()->roles as $user_role) {
$classes[] = 'role-'. $user_role;
}
}
return $classes;
}
add_filter('body_class','jb_add_role_to_body');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment