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?


I have solved it by myself.

$asset = $user->getFieldValue(FIELDHANDLE)->one();
$user->setFieldValues([ 'FIELDHANDLE' => $asset->filename ]);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.