Movable Type 4.2: Custom Fields on registration / sign up form
This is a blog post about Movable Type development. If you are uninterested in Movable Type development, then you don’t need to read this. I have been working on building a pretty substantial website with Movable Type for the last couple of months and have learned a few things along the way. This is one of those things that I learned that isn’t really documented anywhere. I thought I would try.
The website that I am building allows for users to signup/create usernames/login/post entries/etc. The goal was to require a user, when signing up, to add what company they worked for. This is not one of the standard fields that come with Movable Type’s sign up form (we purchased the Community Solution). What is baked in to Movable Type is the ability to create custom fields on the user object. This is good. It means that we can add as many fields as we want, and associate the data to a specific user, (i.e. Company, Job Title, Birthday, etc.). MT has some documentation on allowing a user to update this custom information on their profile page (http://www.movabletype.org/documentation/community/user-profiles.html). Here is the code they suggest:
<mt:loop name="field_loop">
<mt:if name="__first__">
<input type="hidden" name="customfield_beacon" value="1" id="customfield_beacon" />
</mt:if>
<mtapp:setting
id="$field_id"
label="$name"
hint="$description"
shown="$show_field"
show_hint="$show_hint"
required="$required">
<mt:var name="field_html">
</mtapp:setting>
</mt:loop><br />
This is great if you want a user to be able to enter all of the created custom field data at once because it just loops through all of your custom fields and creates input fields for each of them. We had about 10 custom fields on the user object and only wanted the person signing up to enter the ‘Company’ information on signup (as to not make them feel overwhelmed with so much information to input).
How I accomplished only writing one field is to throw an MT if statement in there based on what the $field_id is. In other words what your custom field’s basename is preceded by “customfield_”.
<mt:if name="field_id" eq="customfield_company">
</mt:if>
With “company” my field’s basename, that made the field_id I was looking for, customfield_company.
My final code to display only the company custom field on the user signup form (with MT4.2):
<mt:loop name="field_loop">
<mt:if name="__first__">
<input type="hidden" name="customfield_beacon" value="1" id="customfield_beacon" />
</mt:if>
<mt:if name="field_id" eq="customfield_company">
<mtapp:setting
id="$field_id"
label="$name"
hint="$description"
shown="$show_field"
show_hint="$show_hint"
required="$required">
<mt:var name="field_html">
</mtapp:setting>
</mt:if>
</mt:loop><br />
Note: This is only possible on the user registration page after the release of MovableType 4.2. Before that, I think this could only be done on the profile page.
I will update this if I learn any discrepancies in what I said. If you find any, please let me know.
September 18th, 2008 at 2:41 am
Nice work. Once you filter out the fields you want, you can list the remainder by using this conditional and listing the fields you’ve already listed as a pipe separated list in parentheses like this:
<mt:unless name="field_id" like="(customfield_company|customfield_title)">…code here…
</mt:unless>
September 18th, 2008 at 3:16 pm
Thanks Beau. I will look back through my code and see if I can use this anywhere. It might be nice for grouping specific custom fields together.
October 31st, 2008 at 9:49 am
I’ve heard some good things about this blog. Remember to balance the pics with the text tho. cheers!
November 20th, 2008 at 11:20 am
There has come winter

It became cold and cloudy!
Mood very bad
Depression Begins