Hide Tags and Badges from Hamburger only for guests

I want the logged out user interface as simple as possible so I was wondering if I could hide tags and badges from the hamburger Menu only for guests.

I know this can be done easily with CSS from this post -

But how do I check for the condition that user is a guest and then hide menu items? I probably need to call a function to check this ( just like WordPress) but I have no idea how that would work in Discourse. Can someone please help?

Anonymous users have an anon class you can target, so you could use something like:

.anon {
.hamburger-panel .menu-panel {
  a.latest-topics-link,
  a.top-topics-link,
  a.badge-link,
  li a.categories-link { 
    display: none
   }
  }
} 

(I just added the anon class to the example from the other topic. You would need to tweak it to hide the specific things you wanted)

3 Likes

This worked like a charm. Thank you! Only thing left to hide is the tags link but it does not seem to have it’s own class. How do I target it? With widget-link class it hides the About, FAQ and Mobile View links.

1 Like

This one seems promising:

1 Like

Perfect. This is the final code that worked. I also hide the separator bar. Thank Jammy!

/*hide tags and badges link from hamburger menu for guests */
.anon {
.hamburger-panel .menu-panel {
  a.latest-topics-link,
  a.top-topics-link,
  a.badge-link,
  li a.widget-link[href="/tags"],
  .menu-container-general-links
    { 
    display: none
   }
  }
}
3 Likes

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