Adding extra fields to User

Topics: Customizing Orchard
Jul 6, 2011 at 8:24 AM

Hi there,

I have just created a module inorder to add two new fields to the User Content type (I intend to add more later).  However with the latest downloaded version of the source when I started it up and went to Content/Content Types User does not show up. It did however showup in another version of I had installed....

Is there a way of revealing the User type so that I can add Parts to it.

Kind Regards



Ps if this is not the way to add extra fields (including, later drop downs) then what is the preferred way?

Jul 6, 2011 at 8:48 AM

is the module that first set up that content type installed in the new system?

Jul 6, 2011 at 11:28 PM
Edited Jul 6, 2011 at 11:33 PM

I must be missing something here... is there a module for "User" that shouldbe attached?

Actually there is a module right at the bottom called users under "Modules/Features" and its enabled - there is no option to disable it.

Jul 6, 2011 at 11:37 PM

You can only add parts to User through code.

Jul 6, 2011 at 11:38 PM

So what do you do if you want to add an address or extra identifiers to a user? I would have thought this would have been a process of adding a part to a user?

Jul 6, 2011 at 11:40 PM

You do it through code, or you use one of the modules from the gallery that enable it.

Jul 7, 2011 at 12:05 AM

Ok so I have created a module with two fields and it compiles etc.  Its able to be enabled and it is. 

I am now assuming there is some extra piece of code that causes my part to be able to be attatched however I thought it was:

ContentDefinitionManager.AlterPartDefinition(typeof(UserInfoPart).Name, builder => builder.Attachable());

Which is in the migration file. 

Either way I dont seem to have User showing up in "Content/Content Types" in order to attach a part.....


Here is my migration file as it stands.

using System;
using System.Collections.Generic;
using System.Data;
using Orchard.ContentManagement.Drivers;
using Orchard.ContentManagement.MetaData;
using Orchard.ContentManagement.MetaData.Builders;
using Orchard.Core.Contents.Extensions;
using Orchard.Data.Migration;
using UserInfo.Models;

namespace UserInfo
    public class Migrations : DataMigrationImpl

        public int Create()
            // Creating table UserInfoRecord
            SchemaBuilder.CreateTable("UserInfoRecord", table => table
                .Column("Address1", DbType.Double)
                .Column("Address2", DbType.Double)

                       ContentDefinitionManager.AlterPartDefinition(typeof(UserInfoPart).Name, builder => builder.Attachable());

            return 1;

Jul 7, 2011 at 12:09 AM

I also have Profile enabled... wondering if that would enable Users to be displayed so as to allow my part to be attached?

Jul 7, 2011 at 12:40 AM

To make it appear there you would have to alter the content type, not your part. What I was suggesting is different, I was suggesting that you attach the part to the type from your migration, not that you enable the user to do it from the UI. Why did you want to do it from the admin?

Jul 7, 2011 at 6:44 AM

My intention was to extend the number of fields that is required to register.  We would like to have the address and full name etc as part of the registration process. To this end I looked at the profile module and was unable to get it to work. In particular I enabled it in the module section but the user type did not appear in the content types area.

Is there something that I am missing with this module (why wont it display the user type uder content types).... and.... is this the approach to take with having extra fields for the register page?


Kind Regards


Jul 7, 2011 at 8:36 PM

It is still not clear to me why you would want to do it from the admin instead of just doing it once and for all from the migration code. The user type doesn't appear because it's not been marked creatable, I think, but again I don't think you need to change that for your scenario.

Feb 8, 2015 at 7:08 PM

Sorry to pull this up again, but I'm feeling a bit confused with the user extra fields.

Does anyone have a clear solution how to add extra fields to the user registration form without overriding the AccountController?

Feb 8, 2015 at 7:41 PM
With the upcoming 1.9 release you'll be able to do exactly that using the new Dynamic Forms module. With that release a blog post will be published taking you through that process step by step. So, ehm. Stay tuned!
Feb 8, 2015 at 10:09 PM
Hey sfmskywalker,

Thanks for your quick answer! I guess I'll develop everything else as I can live without it for now.

Btw, you are making a great job with your posts... I've been learning Orchard, mostly following your blog.
Feb 8, 2015 at 10:47 PM
You're welcome, and thank you!