4

Trying to get the currently logged in user's groups. Trying to get at that by using the user ID. I am currently testing as Admin - user number 1.

Craft::$app->getUser()->id

Returns a user ID (11) that does not exist in the Users table. The Users table has ID's of 1, 20, 21.

How do I get user ID or more specifically, the currently logged in user's groups?

12
Craft::$app->getUser()

returns only the user service/component. You should read the docs about that

What you want is the current Identity

Craft::$app->getUser()->getIdentity()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.