CSS class for logged in and logged out users not working

Hello!

I’m using this CSS class to hide things for logged out users but isn’t working for hivepress

// Add CSS class for logged in and logged out users
add_filter('body_class','er_logged_in_filter');
function er_logged_in_filter($classes) {
if( is_user_logged_in() ) {
$classes[] = 'logged-in-condition';
} else {
$classes[] = 'logged-out-condition';
}
// return the $classes array
return $classes;
}

Think it does this by default. It adds the class “logged-in” to the body. You don’t need a class for logged-out, as the absent of “logged-in” means the user is logged out

So can you can give me a solution to hide Hivepress search form, listenings, listening categories and vendors from users who aren’t sign in yet?

I am a starter in wordpress, i took that css from a tutorial and it works for wordpress default text, photos, etc.

Thank’s

Then you need to use something else than CSS, because that can be reverse engineered in the browser.

You need to prevent it from being accessible with some php snippets i think.

Hi,

Please try this CSS snippet:

body:not(.logged-in) .hp-form--listing-search{
  display: none;
}

Please note that it hides it on the page, so those who know how to use DevTools will still be able to search.

Thank’s