<p>If someone lands here searching for a Twig answer like me.</p>

<pre><code>{{ currentUser.customFieldHandle }}
</code></pre>

CC BY-SA 4.0
2020-01-20T22:09:12.780Z
2020-01-20T22:09:12.780Z
Jessica Talzor
<p>You should be able to access the custom fields on element\user object. </p>

<pre class="lang-PHP prettyprint-override"><code>Craft::$app-&gt;getUser()-&gt;getIdentity()-&gt;getFieldValue('customfieldname');
</code></pre>

CC BY-SA 4.0
2020-01-20T22:02:41.330Z
What about in twig?
Jessica Talzor
CC BY-SA 4.0
2018-09-17T23:53:23.803Z
2018-09-18T06:12:58.837Z
2018-09-18T06:12:58.837Z
Dasun Rathnayake
<p>I have following custom fields for users.</p>

<pre><code>favouriteEntries - 'entry' type field with multiple entries per user
notificationPreference - Lightswitch field
</code></pre>

<p>My plugin should email notifications to users who follow that entry when there is an update to a particular entry (<code>Entry::EVENT_AFTER_SAVE</code>).</p>

<pre><code>use craft\elements\User;

$users = User::find()-&gt;all();
</code></pre>

<p>With the above code, I can get all user data including <code>notificationPreference</code> but <code>favouriteEntries</code>. <code>favouriteEntries</code> field returns <code>null</code> even if it has entries for all users. </p>

<p>What's the correct way to get all user data including <code>favouriteEntries</code> field?</p>

CC BY-SA 4.0
2018-09-17T10:22:56.247Z
`favouriteEntries` should never ever return null in no case since it will always contain an object of type `ElementQuery`. Could you eventually show your entire code?
Robin Schambach
<plugin-development><craft3><users>
Craft 3 How to get custom user field values
# Craft 3 How to get custom user field values

(Asked by: username_0 on 2018-09-17)

I have following custom fields for users.
favouriteEntries - 'entry' type field with multiple entries per user
notificationPreference - Lightswitch field

My plugin should email notifications to users who follow that entry when there is an update to a particular entry (Entry::EVENT_AFTER_SAVE).
use craft\elements\User;

$users = User::find()->all();

With the above code, I can get all user data including notificationPreference but favouriteEntries. favouriteEntries field returns null even if it has entries for all users. 
What's the correct way to get all user data including favouriteEntries field?

**Tags:** plugin-development, craft3, users

> **Comments:**
> **username_1**: `favouriteEntries` should never ever return null in no case since it will always contain an object of type `ElementQuery`. Could you eventually show your entire code?  

---

## 2 answers

### Answer by username_3 on 2018-09-17. Score: 5 | Accepted answer

You should be able to access the custom fields on element\user object. 
Craft::$app->getUser()->getIdentity()->getFieldValue('customfieldname');

> **Comments:**
> **username_2**: What about in twig?  

---

### Answer by username_2 on 2020-01-20. Score: 6

If someone lands here searching for a Twig answer like me.
{{ currentUser.customFieldHandle }}


---

