Show a header link for only certain user groups

I have created a header link using the Custom Header Links component to bring users to their Assigned topics, which seems to achieve.

Is there a way to make this only show to specific user groups?


There’s a theme component that will add someone’s primary group as a class to the page body: GitHub - discourse/discourse-groups-css-classes-in-body (note that if you’re trying to target staff users, they already get a staff class without this component)

So if you have added a custom header link called “foo” you could do something like this to hide it from everyone except a group called “bar”:

.foo-custom-header-links {
  display: none;

body.primary-group-bar {
  .foo-custom-header-links {
    display: block;

Thanks! This worked perfectly. Now I’ll have to think up other ways to use this great functionality…

1 Like