How can I display a field from the currentUser template helper in a blaze template? [SOLVED]

Hi,

The following does not work:

<template name="user_info">
Member since: {{currentUser.createdAt}}
</template>

I have only seen the currentUser built-in template helper used with if like

{{#if currentUser}}
  Log out
{{/if}}

Accessing fields on the currentUser helper work fine in the case that this data is published to the client. In this case the createdAt field is not published on the default user publication so you will not have access to that field unless you publish it.

Yes, data is pusblished on the server and there is a subscription on the client.
Anyway the following does not work:

<template name="user_info">
Member since: {{currentUser.createdAt}}
</template>

I’m not sure exactly what issue you may be having, but this works fine when data is available. Just to make sure I wasn’t mistaken, since it has been several years since I’ve used BlazeJS, I’ve cloned an modified the todos example app and added a publication to publish the createdAt field and modified the App_body template to display {{currentUser.createdAt}}

Screenshot%20from%202018-03-08%2010-45-11

1 Like

copleykj thanks for your reply
I also have the todos example app as reference and I added {{currentUser._id}} to the template and it works, I can see the user _id on the browser.

I swear it was not working for me but now it is.
Thanks so much.

1 Like