<p>Custom field data is accessible via <code>currentUser.getContent()</code>.</p>

<p>Using <code>dump</code>:</p>

<pre><code>{{ dump(currentUser.getContent()) }}
</code></pre>

<p>Or to output as string:</p>

<pre><code>{{ currentUser.getContent()|join(', ') }}
</code></pre>

CC BY-SA 3.0
2015-04-23T11:18:30.390Z
Cheers dump brings back the object. But the output as string fails with 'Array to string conversion' error. I've also tried:

[code]{% set profile = currentUser.getContent() %}

{% for key, value in profile %}
  {{ value }}
  {{ key }}
{% endfor %}
Lettie
CC BY-SA 3.0
2015-04-23T16:15:26.833Z
Hmm... 'join' works fine for me on my test DB. Maybe one of the fields is being returned as an array. Possibly a matrix or table field?
Douglas McDonald
CC BY-SA 3.0
2015-04-28T09:25:53.890Z
yep that is exactly what was happening. I added a check to see if any returned data was also an array and it now works fine. Thanks
Lettie
CC BY-SA 3.0
2015-04-22T18:22:51.327Z
2015-04-22T18:22:51.327Z
Douglas McDonald
<p>Hi I'm sure this is simple but it is eluding me. I want to pull out all the user profile fields with twig as an array that I can then check. When I dump the user or currentUser data it does not show any of the profile fields I have created in the returned object. I can however still access these fields with user.customfieldname. How can I return the array I am looking for?</p>

CC BY-SA 3.0
2015-04-22T18:23:56.750Z
You might want to check out a plugin called inspector, which outputs all methods, attributes, etc, all nicely formatted. `{{ currentUser.getContent()|inspect }}`
Douglas McDonald
<templating><user-profile><usermodel>
How can I return all user custom profile fields in an array?
# How can I return all user custom profile fields in an array?

(Asked by: username_0 on 2015-04-22)

Hi I'm sure this is simple but it is eluding me. I want to pull out all the user profile fields with twig as an array that I can then check. When I dump the user or currentUser data it does not show any of the profile fields I have created in the returned object. I can however still access these fields with user.customfieldname. How can I return the array I am looking for?

**Tags:** templating, user-profile, usermodel

> **Comments:**
> **username_1**: You might want to check out a plugin called inspector, which outputs all methods, attributes, etc, all nicely formatted. `{{ currentUser.getContent()|inspect }}`  

---

## 1 answers

### Answer by username_1 on 2015-04-22. Score: 2 | Accepted answer

Custom field data is accessible via currentUser.getContent().
Using dump:
{{ dump(currentUser.getContent()) }}

Or to output as string:
{{ currentUser.getContent()|join(', ') }}

> **Comments:**
> **username_0**: Cheers dump brings back the object. But the output as string fails with 'Array to string conversion' error. I've also tried:  [code]{% set profile = currentUser.getContent() %}  {% for key, value in profile %}   {{ value }}   {{ key }} {% endfor %}  
> **username_1**: Hmm... 'join' works fine for me on my test DB. Maybe one of the fields is being returned as an array. Possibly a matrix or table field?  
> **username_0**: yep that is exactly what was happening. I added a check to see if any returned data was also an array and it now works fine. Thanks  

---

