# CSS classes for group membership? (For simplified UI mode)

**URL:** https://meta.discourse.org/t/css-classes-for-group-membership-for-simplified-ui-mode/60838
**Category:** Support
**Created:** [April 12, 2017, 12:39pm UTC](https://meta.discourse.org/t/css-classes-for-group-membership-for-simplified-ui-mode/60838 "2017-04-12T12:39:34Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![DeanMarkTaylor](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/deanmarktaylor/32/102462_2.png) [@DeanMarkTaylor](https://meta.discourse.org/u/DeanMarkTaylor)
#### Post date: [April 12, 2017, 10:04pm UTC](https://meta.discourse.org/t/css-classes-for-group-membership-for-simplified-ui-mode/60838/2 "2017-04-12T22:04:41Z")

</div>

There might be something that exists in Discourse already - but I personally don’t know of it…

Here is some code I wrote a long time ago and it still appears to work…  
… however there is probably a far better way.

It may / may not help you.

# For a specific username

```plaintext
<script>
if (window.jQuery) {
    window.jQuery(function ($) {
        var u = Discourse.User.current();
        if (u && (u.username === 'DeanMarkTaylor' || u.username === 'BobTheBuilder')) {
	    // Here is where you could add a CSS class to the HTML / body tag
        }
   });
});
</script>

```

# For a user in a specific group

This has the downside of making an additional HTTP request for the initial page load to get the user’s details.

```HTML
<script>
if (window.jQuery) {
    window.jQuery(function ($) {
        var u = Discourse.User.current();
        u.findDetails().then(function(u) {
            // Output the groups for the user
            console.log(u.groups);
	     // Here is where you could add a CSS class to the HTML / body tag
    });
});
</script>

```

---

_[View the full topic](https://meta.discourse.org/t/css-classes-for-group-membership-for-simplified-ui-mode/60838)._
