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

CC BY-SA 4.0
2020-04-29T19:22:43.690Z
2020-04-29T19:22:43.690Z
Kota.M
<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>

<plugin-development><craft3><assets><user-profile><assets-field>
How to work getFieldValue for assets
# 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 ]);


---

