# Add group options to Advertising Plugin

**URL:** https://meta.discourse.org/t/add-group-options-to-advertising-plugin/86768
**Category:** Support
**Tags:** advertising
**Created:** [May 4, 2018, 3:17pm UTC](https://meta.discourse.org/t/add-group-options-to-advertising-plugin/86768 "2018-05-04T15:17:49Z")
**Posts on this page:** 1
**Showing post:** 8

<div class="post-metadata">

### Author: ![bartv](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bartv/32/130052_2.png) [@bartv](https://meta.discourse.org/u/bartv)
#### Post date: [November 25, 2018, 7:46am UTC](https://meta.discourse.org/t/add-group-options-to-advertising-plugin/86768/8 "2018-11-25T07:46:52Z")

</div>

I’ve achieved this with the following code that adds the users’s groups to the body tag:

```plaintext
<script>
// https://meta.discourse.org/t/css-classes-for-group-membership-for-simplified-ui-mode/60838/2
if (window.jQuery) {
    window.jQuery(function ($) {
        var u = Discourse.User.current();
        if (u !== null){
            u.findDetails().then(function(u) {
                // console.log(u.groups);
    	        var arrayLength = u.groups.length;
                for (var i = 0; i < arrayLength; i++) {
    	            $('body').addClass('group-'+u.groups[i].name);
    	        }
            });
        }
    });
};
</script>

```

This code performs one additional call to the Discourse API to fetch the group information, but only once during the initial page load so the impact is minimal.

Next, target the right groups in CSS and hide banners for them:

```plaintext
/* remove ads for Patreon supporters */
.group-patreon-casual .google-adsense,
.group-patreon-commercial .google-adsense,
.group-patreon-serious .google-adsense {
	display:none;
}

```

---

_[View the full topic](https://meta.discourse.org/t/add-group-options-to-advertising-plugin/86768)._
