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 (http://www.movabletype.org/documentation/community/user-profiles.html). 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.

22 Comments:

  1. 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:


    …code here…

  2. 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.

  3. Just thought i would comment and say neat theme, did you code it yourself? Looks great.

  4. Good information. Tweeted about it. I’ll bookmark this place too.

  5. Well, I don’t know if that’s going to work for me, but definitely worked for you! :) Excellent post!

  6. Thanks for the post it educated me haha.

  7. Greetings. To start with I want to say that I genuinely like your website, just discovered it the past week but I’ve been following it constantly since then.

    I appear to concur with most of your thinkings and beliefs and this submit is no different. absolutely agree with you.

    Thank you for the wonderful weblog and I hope you preserve up the good do the job. If you do I will keep on to browse it.

    Use a wonderful day.

  8. Great post! I am sure most people will love this :)

    -Rickie Evey

  9. This is just the sort of info I was looking for! Thanks :)

  10. I have read few of articles here and could say it was really interesting, thanks for sharing this.

  11. It was extremely interesting for me to read that blog. Thanx for it. I like such themes and everything that is connected to this matter. I definitely want to read a bit more soon.

    Bella Benedict
    laois escorts

  12. Hi this site of your blog was very interesting for me. But it was difficult to find it with google.com. Maybe you should improve it with seo plugins for wordpress like WP seo.

  13. Skip Hop Studio Diaper Tote Handbag is awesome.So several wallets – and also not really those modest, useless pockets, either. Almost all of the pockets tend to be a great size and genuinely support keep everything organized. The handles are a wonderful length and fit nicely more than the actual shoulder; the tackle straps also remain put on my own shoulder, which is actually critical as soon as you are having a infant. The bag appears excellent, too. Not as well fancy, but not as well casual. (I have it in black) The material is soft (can’t assume of a superior word) so it is uncomplicated to squeeze in to tight spaces – but yet it is sturdy. I’ve a Fleurville Lexi tote and I really like it, as well, but this handbag is kind of rigid. I think that Skip*Hop will turn out to be my everyday handbag. It is a bit significant – so if you are not really in to large totes this may well be much better as an over-night baby diaper bag.

  14. thank you, very informative & useful. keep up the good work

  15. I LIKE YOUR BLOG I GOT IT FROM A FRIEND ON BINGI WILL COME BACK FOR MORE INFO THANKS.

  16. some truly excellent information, Gladiolus I discovered this.

  17. Please, can you Pm me and tell me few much more thinks about this, I am seriously fan of your weblog… 34

  18. Really nice style and design and wonderful written content , nothing else we require : D.

  19. We got some great sex costumes for youre partner!

  20. Greetings! This is my 1st comment here so I just wanted to give a quick shout out and tell you I genuinely enjoy reading through your posts. Can you suggest any other blogs/websites/forums that go over the same topics? Thanks a lot!

  21. Pretty nice blog post. I just stumbled upon your weblog and wanted to say that I have truly enjoyed surfing around your blog site blogposts. After all I’ll be subscribing to your feed and I hope you write again very soon!

  22. Heya i am for the first time here. I came across this board and I find It truly useful & it helped me out much. I hope to give something back and aid others like you aided me. Best wishes,

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