Have you needed to have a class added to your body for a particular job. Maybe you just need one added or maybe you need one added based on the user role – have you ever wanted to know how to add the user role as a class name to the body? Below are two snippets to add to your functions.php file.

You can use the user role class to customise the page (using CSS) based on the user or you can hide sections/modules. 

Add class on all pages
Add user role class on all pages - for example role-customer