Variable for User Field How do I go about using a dynamic value to access a user field value? I have created a form builder for users and dynamically populate the user field based on the question's associated field. 

&lt;input name="fields[{{ question.fieldName }}]"&gt;


This works nicely but I am looking to pre-populate this input with a value if the user has previously provided and saved this info but I'm having trouble figuring out how to combine the field name with currentUser.

My first try was:

{% set fieldName = question.fieldName %}
{{ currentUser.fieldName }}


But that returns the following error:

Craft\UserModel and its behaviors do not have a method or closure named "fieldName".

Any help would be greatly appreciated
You could try using the attribute function in twig, this should let you call dynamic properties.

Something like:

{{ attribute(currentUser, question.fieldName) }}