Body class for different user type accounts

Hi there Team HP.

Would it be possible to add a different CSS class to the body element of the pages for the Buyer and Host type accounts?
This would just make things a whole lot easier if we want to style common elements across both accounts differently depending on account type.

Please try this PHP code snippet.

add_filter(
	'body_class',
	function($classes){
		if(!is_user_logged_in()){
			return $classes;	
		}
		
		if(current_user_can('edit_posts')){
			$classes[] = 'vendor-class';
		}else{
			$classes[] = 'user-class';
		}
		
		return $classes;
	},
	1000
);
1 Like

THANKS Yevhen!

That makes some of the CSS a lot simpler, so could it not be part of the default HP, so users don’t have to scroll through Community posts to find this code snippet? :upside_down_face:

Hi,

Thank you for your feedback, we will consider including these classes in future updates.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.