# User JS Object \`groups\` array not populated for several users

**URL:** <https://meta.discourse.org/t/user-js-object-groups-array-not-populated-for-several-users/261520>\
**Category:** Development\
**Created:** [April 13, 2023, 2:02am UTC](https://meta.discourse.org/t/user-js-object-groups-array-not-populated-for-several-users/261520 "2023-04-13T02:02:24Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![angus](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/angus/32/341715_2.png) [@angus](https://meta.discourse.org/u/angus)\
**Post date:** [April 13, 2023, 2:17am UTC](https://meta.discourse.org/t/user-js-object-groups-array-not-populated-for-several-users/261520/2 "2023-04-13T02:17:35Z")

</div>

> [@smileBeda](#):
>
> Can anyone help me spot _why_ this happens

You’re using the session endpoint for the currently logged in user (i.e. `session/current`). Only staff members will get the “automatic” groups (e.g. trust level groups) from that endpoint.

For an example of that check out [https://meta.discourse.org/g](https://meta.discourse.org/g). It’s not the same endpoint, but the same principle applies. You’ll see that you can’t see all the trust level groups on meta, because you’re not a staff member on this forum.

You’ll need to use an authenticated request, i.e. with an API key, to get all of a user’s groups, including automatic groups. If this javascript is running on Wordpress you can use the [WP Discourse](https://github.com/discourse/wp-discourse) utility functions to do this. It’ll make a request using the API key you’ve supplied in the admin interface.

---

_[View the full topic](https://meta.discourse.org/t/user-js-object-groups-array-not-populated-for-several-users/261520)._
