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 https://forum.domain.net/my/activity/assigned seems to achieve.

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

2 Likes

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;
  }
}
3 Likes

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

1 Like