Answers.Body: <p>If someone lands here searching for a Twig answer like me.</p>
  
  <pre><code>{{ currentUser.customFieldHandle }}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-01-20T22:09:12.780Z
Answers.LastActivityDate: 2020-01-20T22:09:12.780Z
Answers.UserDisplayName: Jessica Talzor
Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-01-20T22:02:41.330Z
Answers.Text: What about in twig?
Answers.UserDisplayName: Jessica Talzor
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-09-17T23:53:23.803Z
Answers.LastActivityDate: 2018-09-18T06:12:58.837Z
Answers.LastEditDate: 2018-09-18T06:12:58.837Z
Answers.UserDisplayName: Dasun Rathnayake
Body: <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>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-09-17T10:22:56.247Z
Comments.Text: `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?
Comments.UserDisplayName: Robin Schambach
Tags: <plugin-development><craft3><users>
Title: Craft 3 How to get custom user field values
ThreadText: # 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.
  
  ```PHP
  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 }}
  
  ```
  
  
  ---
  
  