How to check for a users custom groups?

groups
admin

(Steven Slade) #1

In Discourse/Admin/Groups there are automatic groups and custom groups. I am trying to identify users based off of their custom groups. In the same way you can do Discourse.User.current(), I am hoping there is something similar for querying the custom groups they have been added to.


#2

Sorry for necroposting, but I need this and I haven’t found anything related to it.


(Rafael dos Santos Silva) #3
Discourse.User.current().groups.forEach((g) => { console.log(g.name); });

#4
TypeError: Discourse.User.current(...).groups is undefined
Discourse.User.current().groups.forEach((g) => { console.log(g.name); });

I get this error when I try to get it :confused:


(Rafael dos Santos Silva) #5

The groups field gets filled in some pages, like on your profile.


How to add external link on top menu?
#6

I see… Would it be possible to get this info externally like grabbing the current/session.json?


(Rafael dos Santos Silva) #7

In a plugin? For sure!