# Does exist JavaScript if is admin or if is group?

**URL:** <https://meta.discourse.org/t/does-exist-javascript-if-is-admin-or-if-is-group/85725>\
**Category:** Product Support\
**Created:** [April 19, 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

## AI-generated summary

In a support discussion regarding JavaScript capabilities in Discourse, [Daniel_Nevoigt](/t/-/85725/1) asks if it is possible to conditionally display content based on whether a user is an admin or belongs to a specific group. [cpradio](/t/-/85725/2) confirms this is achievable using the `Discourse.User.current()` method. They explain that if this method returns a user object (rather than null), the object includes an `admin` property. However, [cpradio](/t/-/85725/2) notes that group information is not immediately available in the initial user object and may require a secondary API call to retrieve. [Daniel_Nevoigt](/t/-/85725/3) subsequently thanks [cpradio](/t/-/85725/2) for the clarification.

<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:** [April 19, 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:** [April 19, 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:** [April 19, 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:** [June 8, 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>

Closed on June 8, 2024, 12:37pm UTC

This topic was automatically closed after 2241 days. New replies are no longer allowed.
