# Creating a banner that only 1 group can see, while the other groups don't

**URL:** <https://meta.discourse.org/t/creating-a-banner-that-only-1-group-can-see-while-the-other-groups-dont/221253>\
**Category:** Product Support\
**Created:** [March 17, 2022, 5:43pm UTC](https://meta.discourse.org/t/creating-a-banner-that-only-1-group-can-see-while-the-other-groups-dont/221253 "2022-03-17T17:43:35Z")\
**Posts on this page:** 8\
**Page:** 1

## AI-generated summary

A user seeks a way to display a banner exclusively to members of the "trial" group in Discourse, while hiding it from paying members and users without accounts. [santiyounger](/t/-/221253/1) initially explores using the Versatile Banner plugin but faces limitations with visibility and closing permissions. [JammyDodger](/t/-/221253/2) suggests a CSS solution using the `primary-group-trial` class, which works only if "trial" is the user's primary group. [santiyounger](/t/-/221253/3) notes this is a limitation since some users have different primary groups. [JammyDodger](/t/-/221253/5) then proposes using the `anon` class to show the banner to unauthenticated users. [tshenry](/t/-/221253/7) recommends the `discourse-groups-css-classes-in-body` plugin, which adds a `body.group-trial` class to allow targeting users in the "trial" group regardless of their primary group, provided they can see the group. [santiyounger](/t/-/221253/8) expresses gratitude and plans to test the solution.

<div class="post-metadata">

**Author:** ![santiyounger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/santiyounger/32/252655_2.png) [@santiyounger](https://meta.discourse.org/u/santiyounger)\
**Post date:** [March 17, 2022, 5:43pm UTC](https://meta.discourse.org/t/creating-a-banner-that-only-1-group-can-see-while-the-other-groups-dont/221253/1 "2022-03-17T17:43:36Z")

</div>

I wrote about this in the [Versatile Banner Plugin Topic](https://meta.discourse.org/t/versatile-banner/109133) but I realized it might work better as it’s own post, so here it is:

Thanks for the awesome tool.

I’m so close to creating what I need. I don’t know if anyone has any ideas, or if this could be implemented into versatile banner.

This is the banner I created

 ![image](https://global.discourse-cdn.com/meta/original/3X/c/0/c08973fd62020307db5aa2233d253771780d345b.png)

However I only want that to appear to people in my Discourse group “trial” I don’t need my paying members to see this banner at all which is why I wrote

> If you are already a member you can close this message

However, that’s still a flawed solution.

Another issue is that the “Learn more” button link is a private link for members in “Trial Mode” since paying members don’t have access to the group where that link takes the user.

Also I wouldn’t want trial members to be able to close the banner, (I only want paying members to be able to close it)

Does anyone know of any work arounds I can do to make the banner only appear to members of the trial group?

I’d love to find a solution with versatile banners, since it looks great, but I’m open to other ideas!

Thanks!

---

<div class="post-metadata">

**Author:** ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)\
**Post date:** [March 17, 2022, 6:18pm UTC](https://meta.discourse.org/t/creating-a-banner-that-only-1-group-can-see-while-the-other-groups-dont/221253/2 "2022-03-17T18:18:00Z")

</div>

My CSS is improving, though still rudimentary 🙂, but I think you could do something like this as long as the Trial group was set to be their primary group:

```plaintext
.banner-box {
	display: none;
}

.primary-group-trial {
   .banner-box {
       display: initial;
   }
}

```

So the first bit hides it from everyone, and the second then shows it to members with the ‘trial’ group as their primary.

---

<div class="post-metadata">

**Author:** ![santiyounger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/santiyounger/32/252655_2.png) [@santiyounger](https://meta.discourse.org/u/santiyounger)\
**Post date:** [March 17, 2022, 6:38pm UTC](https://meta.discourse.org/t/creating-a-banner-that-only-1-group-can-see-while-the-other-groups-dont/221253/3 "2022-03-17T18:38:49Z")

</div>

thank you so much! I’ll experiment with it

unfortunately I do have another primary group set-up for some users. Do you think primary group is the only way? is there no way to just make so as long as someone belongs to “trial group”

If it must be primary, that might be a sacrifice I might have to make since this is a genius solution

Thanks a lot

---

<div class="post-metadata">

**Author:** ![santiyounger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/santiyounger/32/252655_2.png) [@santiyounger](https://meta.discourse.org/u/santiyounger)\
**Post date:** [March 17, 2022, 6:45pm UTC](https://meta.discourse.org/t/creating-a-banner-that-only-1-group-can-see-while-the-other-groups-dont/221253/4 "2022-03-17T18:45:30Z")

</div>

@JammyDodger I totally forgot the fact that I need users without accounts to also see the banner.

In that case do you think there’s a way where instead of only showing to “trial-group”

instead making the CSS so that it’s only hidden from “paid-members group”

That’d be incredible!

---

<div class="post-metadata">

**Author:** ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)\
**Post date:** [March 17, 2022, 7:33pm UTC](https://meta.discourse.org/t/creating-a-banner-that-only-1-group-can-see-while-the-other-groups-dont/221253/5 "2022-03-17T19:33:39Z")

</div>

> [@santiyounger](#):
>
> I totally forgot the fact that I need users without accounts to also see the banner.

It seems that `anon` is a class you can use there as well. 👍 So you could add something like this to the bottom:

```plaintext
.anon {
   .banner-box {
       display: initial;
   }
}

```

> [@santiyounger](#):
>
> Do you think primary group is the only way? is there no way to just make so as long as someone belongs to “trial group”

I think I have seen a way to insert a class, though its not something I’m fluent in. 🙂 I’ll see if I can find the topic I’m thinking of, and check I’ve understood it properly.

---

<div class="post-metadata">

**Author:** ![santiyounger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/santiyounger/32/252655_2.png) [@santiyounger](https://meta.discourse.org/u/santiyounger)\
**Post date:** [March 17, 2022, 9:28pm UTC](https://meta.discourse.org/t/creating-a-banner-that-only-1-group-can-see-while-the-other-groups-dont/221253/6 "2022-03-17T21:28:36Z")

</div>

that’s be incredible, your CSS trick worked incredibly well! the only missing piece would be to achieve it without primary-group, but just as long as someone belongs to that group

---

<div class="post-metadata">

**Author:** ![tshenry](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tshenry/32/119495_2.png) [@tshenry](https://meta.discourse.org/u/tshenry)\
**Post date:** [March 17, 2022, 10:43pm UTC](https://meta.discourse.org/t/creating-a-banner-that-only-1-group-can-see-while-the-other-groups-dont/221253/7 "2022-03-17T22:43:38Z")

</div>

This component should allow you to expose non-primary groups as body tag classes:

[https://github.com/discourse/discourse-groups-css-classes-in-body](https://github.com/discourse/discourse-groups-css-classes-in-body)

I _think_ you’d do something like:

```plaintext
body.group-trial {
   .banner-box {
       display: initial;
   }
}

```

This will only work if the users of the trial group have permission to at least **see** that the group exists.

---

<div class="post-metadata">

**Author:** ![santiyounger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/santiyounger/32/252655_2.png) [@santiyounger](https://meta.discourse.org/u/santiyounger)\
**Post date:** [March 19, 2022, 2:22pm UTC](https://meta.discourse.org/t/creating-a-banner-that-only-1-group-can-see-while-the-other-groups-dont/221253/8 "2022-03-19T14:22:20Z")

</div>

thanks a lot I’ll try that out, that might be the solution I need! thanks @tshenry and @JammyDodger for the incredible help!
