CSS class for logged in and logged out users not working


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
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.


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.


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.


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