You can add in “if” conditions depending.
Example:
add_filter( 'body_class', function( $classes ) {
if(is_user_logged_in()){
return array_merge( $classes, array( 'your-class-name' ) );
} else {
return $classes;
}
} );
What this snippet does is, it checks if the current visitor is logged in. If the visitor is logged in, it adds a custom class. Else(meaning non logged in visitors), it will display the default classes.
A wise man once said:
"Have you cleared your cache?"