Movable Type 4.2: Custom Fields on registration / sign up form

August 21st, 2008

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 ( Here is the code they suggest:

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_”.

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):

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.


Comments have been closed for this post. If you would like to ask a question or need help, please post in the forums.