Answers.Body: <p>I have solved it by myself.</p>
  
  <pre><code>$asset = $user-&gt;getFieldValue(FIELDHANDLE)-&gt;one();
  $user-&gt;setFieldValues([ 'FIELDHANDLE' =&gt; $asset-&gt;filename ]);
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-04-29T19:22:43.690Z
Answers.LastActivityDate: 2020-04-29T19:22:43.690Z
Answers.UserDisplayName: Kota.M
Body: <p>I have been implementing my own PHP plugin code.</p>
  
  <p>In that, I need to get an asset field in user info. If I can get if the asset is set on the field or not, it is enough.</p>
  
  <p>I can get the values of text and radio button fields with <code>$user-&gt;getFieldValue</code> function.
  However, it does not work for asset fields.
  How should I do for asset?</p>
  
Tags: <plugin-development><craft3><assets><user-profile><assets-field>
Title: How to work getFieldValue for assets
ThreadText: # How to work getFieldValue for assets
  
  (Asked by: username_0 on 2020-04-29)
  
  I have been implementing my own PHP plugin code.
  
  In that, I need to get an asset field in user info. If I can get if the asset is set on the field or not, it is enough.
  
  I can get the values of text and radio button fields with `$user->getFieldValue` function.
  However, it does not work for asset fields.
  How should I do for asset?
  
  **Tags:** plugin-development, craft3, assets, user-profile, assets-field
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2020-04-29. Score: 1
  
  I have solved it by myself.
  
  ```
  $asset = $user->getFieldValue(FIELDHANDLE)->one();
  $user->setFieldValues([ 'FIELDHANDLE' => $asset->filename ]);
  
  ```
  
  
  ---
  
  