July 11, 2018
I’ve worked with a few membership-based websites, and found this method to be the easiest way to ensure layout customization for different user types:
add_filter('body_class','add_role_to_body'); function add_role_to_body($classes) { $current_user = new WP_User(get_current_user_id()); $user_role = array_shift($current_user->roles); $classes[] = 'role-'. $user_role; // change prefix as desired return $classes; }