Answers.Body: <p>You can do this by going via the element's field layout:</p>
  
  <pre class="lang-php prettyprint-override"><code>$user = \craft\elements\User::find()-&gt;id(1)-&gt;one();
  
  $fields = $user-&gt;getFieldLayout()-&gt;getFields();
  </code></pre>
  
  <p>This will return you an array of all the fields (fields, <strong>not</strong> values) attached to your user.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-03-31T10:18:16.653Z
Answers.Text: yes It is working. Thanks man..
Answers.UserDisplayName: Amit Senjaliya
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-03-31T10:05:00.367Z
Answers.LastActivityDate: 2020-03-31T10:05:00.367Z
Answers.UserDisplayName: Oli
Body: <p>I have created fields for users and also entry type.
  I want to get only users fields. I have retrieved custom fields but that returns all the fields.</p>
  
  <pre><code>$users = \craft\elements\User::find()-&gt;id(USERID)-&gt;one();
  print_r($users-&gt;getbehaviors()['customFields']);
  </code></pre>
  
  <p>I know how to get user custom fields with field Handle.
  I need only users fields (whole users fields not single) that admin assign in the CP. ( settings/users/fields ).</p>
  
Tags: <users><custom-field>
Title: How can retrieve users custom fields only?
ThreadText: # How can retrieve users custom fields only?
  
  (Asked by: username_0 on 2020-03-31)
  
  I have created fields for users and also entry type.
  I want to get only users fields. I have retrieved custom fields but that returns all the fields.
  
  ```
  $users = \craft\elements\User::find()->id(USERID)->one();
  print_r($users->getbehaviors()['customFields']);
  
  ```
  
  I know how to get user custom fields with field Handle.
  I need only users fields (whole users fields not single) that admin assign in the CP. ( settings/users/fields ).
  
  **Tags:** users, custom-field
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-03-31. Score: 2 | Accepted answer
  
  You can do this by going via the element's field layout:
  
  ```php
  $user = \craft\elements\User::find()->id(1)->one();
  
  $fields = $user->getFieldLayout()->getFields();
  
  ```
  
  This will return you an array of all the fields (fields, **not** values) attached to your user.
  
  > **Comments:**
  > **username_0**: yes It is working. Thanks man..  
  
  ---
  
  