# \[Widget\] Menu based on group permission

**URL:** https://meta.discourse.org/t/widget-menu-based-on-group-permission/91997
**Category:** Development
**Created:** [July 10, 2018, 4:15pm UTC](https://meta.discourse.org/t/widget-menu-based-on-group-permission/91997 "2018-07-10T16:15:20Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![tanzaho](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tanzaho/32/119781_2.png) [@tanzaho](https://meta.discourse.org/u/tanzaho)
#### Post date: [July 10, 2018, 4:15pm UTC](https://meta.discourse.org/t/widget-menu-based-on-group-permission/91997/1 "2018-07-10T16:15:21Z")

</div>

I have a navigation menu built with the `api.decorateWidget` method.

Here is an example from my template, file:

```
<script type="text/discourse-plugin" version="0.2">
api.decorateWidget('home-logo:after', helper => {
    const showExtraInfo = helper.attrs.minimized;
        if(!showExtraInfo) {
            return helper.h('ul.nav-link-container', [
                helper.h('li.hidden-for-mobile', [
                    helper.h('a.nav-link', {
                        href:'https://myforum.com/publicCategory',
                        text:'My Public Category',
                        target:'_self'
                    })
                ]),
                helper.h('li.hidden-for-mobile', [
                    helper.h('a.nav-link', {
                        href:'https://myforum.com/privateCategory',
                        text:'My Private Category',
                        target:'_self'
                    })
                ])
           ]);
        }
});
</script>

```

It works fine, and allows connected users to visit my public and private categories.

Now, I would like to hide the second link based on group permissions.  
It seems very complicated to me since I didn’t look into Discourse widgets documentation, and I fear that this behavior is not possible.

Can anyone tell me if I could change/hide the link based on the current user groups? If yes, in what direction should I start looking?

---

<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: [July 10, 2018, 4:51pm UTC](https://meta.discourse.org/t/widget-menu-based-on-group-permission/91997/2 "2018-07-10T16:51:43Z")

</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(function (g) {
                return g.name === 'MyGroupName';
            })) {
                // User is member of the group
            }
        });
    }
</script>

```

This will incur in an extra network request for `.findDetails` but works.
