11

This question is similar to this post, but more of the next logical step.

I have added custom fields to my user profiles, but would like these attributes to be part of the registration page.

For example I'd like the user to specify their address on sign up, but I haven't found a way to reference this field correctly in the page.

Something like:

<h3><label for="Address">Address</label></h3>
<input id="Address" type="text" name="Address"
    {%- if account is defined %} value="{{ account.Address}}"{% endif -%}>

{% if account is defined %}
    {{ errorList(account.getErrors('Address')) }}
{% endif %}

This doesn't work because account.Address doesn't seem to be the correct way to access custom user fields on registration, and the only way I currently know how to access this field would be through currentUser.Address, but that relies on the account all ready being created.

Does anyone know how to access these fields to save during registration, or am I going to have to create the account first then have a second page that allows the user to set these fields?

16

You need to change your input tag from:

<input id="Address" type="text" name="Address"
{%- if account is defined %} value="{{ account.Address}}"{% endif -%}>

To:

<input id="Address" type="text" name="fields[Address]"
{%- if account is defined %} value="{{ account.Address}}"{% endif -%}>

All custom fields input types should have a name prefixed with fields[].

  • No worries... care to mark it as the answer? – Brad Bell Oct 23 '14 at 23:33

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.