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?

Eric Snyder
  • 531
  • 6
  • 14

1 Answers1

13
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()
Robin Schambach
  • 19,713
  • 1
  • 19
  • 44