Does exist JavaScript if is admin or if is group?


(Daniel Nevoigt) #1

Sorry if I that is somehow double post, but I couldn´t find anything, so I ask my noob question :slight_smile:

I am trying to figure out if I can show something to specific user like the admin or a specific group using JavaScript? For example: if user = admin -> show that, else -> show nothing…

Thanks for help again.


(cpradio) #2

Yes you can. The method Discourse.User.current(); is readily available, if it returns null, the user is not logged in, otherwise, it returns a user object, that has properties for admin, and groups.

To access the groups, you might need to make a secondary call to request that information, I’m not seeing it as part of the initial user object.


(Daniel Nevoigt) #3

Thank you very much :slight_smile: