# Check for group membership in Header code?

**URL:** <https://meta.discourse.org/t/check-for-group-membership-in-header-code/72642>\
**Category:** UX\
**Created:** [23 Octubre, 2017 21:03 UTC](https://meta.discourse.org/t/check-for-group-membership-in-header-code/72642 "2017-10-23T21:03:24Z")\
**Posts on this page:** 1\
**Showing post:** 9

<div class="post-metadata">

**Author:** ![Gunnar](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gunnar/32/119647_2.png) [@Gunnar](https://meta.discourse.org/u/Gunnar)\
**Post date:** [28 Octubre, 2017 20:20 UTC](https://meta.discourse.org/t/check-for-group-membership-in-header-code/72642/9 "2017-10-28T20:20:21Z")

</div>

> [@vinothkannans](#):
>
> If a user’s primary group is customers then the body tag will have the CSS class primary-group-customers.

So, should this work then, if I want to display “Member!” if the user is a member of the “patrons” group?

```
<p id="ghjldemo">Not a member!</p>

<script type="text/javascript">
if ( document.getElementById("body").className.match(/(?:^|\s)primary-group-patrons(?!\S)/) ) {
    document.getElementById("ghjldemo").innerHTML = "Member!";
}
</script>

```

Thanks,  
Gunnar

---

_[View the full topic](https://meta.discourse.org/t/check-for-group-membership-in-header-code/72642)._
