<pre><code>Craft::$app-&gt;getUser()
</code></pre>

<p>returns only the user service/component. You should read the <a href="https://docs.craftcms.com/api/v3/craft-services-users.html" rel="noreferrer">docs</a> about that</p>

<p>What you want is the current Identity</p>

<pre><code>Craft::$app-&gt;getUser()-&gt;getIdentity()
</code></pre>

CC BY-SA 3.0
2018-04-28T21:34:43.187Z
2018-04-28T21:34:43.187Z
Robin Schambach
<p>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.</p>

<pre><code>Craft::$app-&gt;getUser()-&gt;id
</code></pre>

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

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

<plugin-development><craft3>
Getting info on the currently logged in user
# Getting info on the currently logged in user

(Asked by: username_0 on 2018-04-28)

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?

**Tags:** plugin-development, craft3

---

## 1 answers

### Answer by username_1 on 2018-04-28. Score: 15 | Accepted answer

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()


---

