# Display different content within a topic based on user's groups membership?

**URL:** <https://meta.discourse.org/t/display-different-content-within-a-topic-based-on-users-groups-membership/227075>\
**Category:** Development\
**Created:** [May 15, 2022, 12:01pm UTC](https://meta.discourse.org/t/display-different-content-within-a-topic-based-on-users-groups-membership/227075 "2022-05-15T12:01:25Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![craigconstantine](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/craigconstantine/32/511195_2.png) [@craigconstantine](https://meta.discourse.org/u/craigconstantine)\
**Post date:** [August 29, 2022, 2:39pm UTC](https://meta.discourse.org/t/display-different-content-within-a-topic-based-on-users-groups-membership/227075/5 "2022-08-29T14:39:42Z")

</div>

I really appreciate your efforts on this… I’m still thinking about this and I think you’ve started me on a workable solution. I’ve a template component I wrote, which makes me think I could make something like this work…

Supposing I imagine a component “foobar”. I could write a topic, adding some DIVs like this…

```plaintext
<div data-custom="foobar" data-foobar="<groupname>">
</div>

```

```plaintext
<div data-custom="foobar" data-foobar="!<groupname>">
</div>

```

The component then deletes from the DOM, one DIV or the other, based on the viewing user’s group.

This strikes me as stronger than a CSS `display: none;` which is trivial to flip back on via any web browser’s DOM inspection features. To get around this, someone would have to alter the j/s that is running when the page loads—possible, but much harder.

# why do I want this?

So I can do a partial reveal of content for people who are NOT in the group. (Because getting into the group requires a paying subscription.)

```plaintext
This is a really cool topic. This first
paragraph is really interesting.

<div data-custom="foobar" data-foobar="<groupname>">
Here's the rest of the content.
</div>

<div data-custom="foobar" data-foobar="!<groupname>">
Hi, sorry to interrupt!
There's more conent here for our paying members...
would you like to read about becoming one?
</div>

```

People in the group simply see the entire topic. There’s no sign of any paywalling.

People not in the group see the initial portion, not in either DIV above, and a paywall.

So I can use this in a completely public area so people can see what they get if they signup, login and become a paying member.

---

_[View the full topic](https://meta.discourse.org/t/display-different-content-within-a-topic-based-on-users-groups-membership/227075)._
