I'm trying to pull out user data in a template for specified user profiles whilst the current user is logged in. To do this I check on the userId being referenced and use:

{% if userId != currentUser.id %}
    {% set userProfile = craft.users.id(userId).getContent() %}
{% endif %}

This returns a user object for that user. However when I try to reference any of the fields custom or otherwise for the userProfile it returns blank apart from on userProfile.id which returns the id of the required user.

So what am I missing? I was under the impression that getContent() would pull out all custom fields and these could simply be accessed by using the dot syntax? Or does this only work on currentUser?


1 Answer 1


If i understand your question correct, you like to output the user data. I don't think that you need the getContent() function. But it's important, that you use the first() function. Here is your code:

{% set userProfile = craft.users.id(userId).first() %}
{{ userProfile.yourFieldname }} 

Hope it works.

  • Cheers overlooked that!
    – Lettie
    Mar 10, 2016 at 18:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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