# Esiste JavaScript se è admin o se è gruppo?

**URL:** https://meta.discourse.org/t/does-exist-javascript-if-is-admin-or-if-is-group/85725
**Category:** Support
**Created:** [19 Aprile 2018, 3:31pm UTC](https://meta.discourse.org/t/does-exist-javascript-if-is-admin-or-if-is-group/85725 "2018-04-19T15:31:53Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Daniel\_Nevoigt](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/daniel_nevoigt/32/92920_2.png) [@Daniel\_Nevoigt](https://meta.discourse.org/u/Daniel_Nevoigt)
#### Post date: [19 Aprile 2018, 3:31pm UTC](https://meta.discourse.org/t/does-exist-javascript-if-is-admin-or-if-is-group/85725/1 "2018-04-19T15:31:53Z")

</div>

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

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.

---

<div class="post-metadata">

### Author: ![cpradio](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cpradio/32/4970_2.png) [@cpradio](https://meta.discourse.org/u/cpradio)
#### Post date: [19 Aprile 2018, 3:34pm UTC](https://meta.discourse.org/t/does-exist-javascript-if-is-admin-or-if-is-group/85725/2 "2018-04-19T15:34:02Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Daniel\_Nevoigt](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/daniel_nevoigt/32/92920_2.png) [@Daniel\_Nevoigt](https://meta.discourse.org/u/Daniel_Nevoigt)
#### Post date: [19 Aprile 2018, 4:17pm UTC](https://meta.discourse.org/t/does-exist-javascript-if-is-admin-or-if-is-group/85725/3 "2018-04-19T16:17:50Z")

</div>

Thank you very much 🙂

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [8 Giugno 2024, 12:37pm UTC](https://meta.discourse.org/t/does-exist-javascript-if-is-admin-or-if-is-group/85725/4 "2024-06-08T12:37:39Z")

</div>

Questo argomento è stato chiuso automaticamente dopo 2241 giorni. Non sono più consentite nuove risposte.
