# Simple Script to Show / Hide Content Based on Group

**URL:** <https://meta.discourse.org/t/simple-script-to-show-hide-content-based-on-group/74761>\
**Category:** Support\
**Created:** [24 Novembre 2017, 8:43pm UTC](https://meta.discourse.org/t/simple-script-to-show-hide-content-based-on-group/74761 "2017-11-24T20:43:54Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)\
**Post date:** [24 Novembre 2017, 9:09pm UTC](https://meta.discourse.org/t/simple-script-to-show-hide-content-based-on-group/74761/2 "2017-11-24T21:09:39Z")

</div>

```plaintext
<script type="text/discourse-plugin" version="0.8">
    var u = api.getCurrentUser();
    if (u !== null) {
        u.findDetails().then(function(u) {
            if (!u.groups.some((g) => g.name === 'patrons')) {

                // user isn't a patron, insert code here

            }
        });
    }
</script>

```

This will work, but will be an extra request on every page load.

---

_[View the full topic](https://meta.discourse.org/t/simple-script-to-show-hide-content-based-on-group/74761)._
