unable to register new user

Topics: Customizing Orchard, Writing modules
Feb 27, 2015 at 7:24 AM
Hello ,

I am trying to register a new user using orchard cms. I modified the registration page of Orchard CMS and added few new fields in it. There are no error/exceptions in the code but the user is not created in the database. Can anyone please tell what possibly could be the reason. Any help would be greatly appreciated
Feb 27, 2015 at 7:31 AM
Can you tell a bit more on how exactly you went about adding the new fields?
Feb 27, 2015 at 7:40 AM
Edited Feb 27, 2015 at 7:40 AM
i added the new fields in the Register.cshtml view and modified the code in the Register() method in AccountController.cs
Feb 27, 2015 at 7:46 AM
Can you share that code?
Feb 27, 2015 at 7:57 AM
Edited Feb 27, 2015 at 10:07 AM
Here is the code :

public ActionResult Register(string Title, string userName, string City, string Country, string ZipPostalCode,string email, string password, string confirmPassword, string returnUrl = null)

// ensure users can register
var registrationSettings = _orchardServices.WorkContext.CurrentSite.As<RegistrationSettingsPart>();
if (!registrationSettings.UsersCanRegister)
return HttpNotFound();

ViewData["PasswordLength"] = MinPasswordLength;

if (ValidateRegistration(userName, Title, City, Country, ZipPostalCode, email, password, confirmPassword))
// Attempt to register the user
// No need to report this to IUserEventHandler because _membershipService does that for us
var user = _membershipService.CreateUser(new CreateUserParams(Title, City, Country, ZipPostalCode,    userName, password, email, null, null, false));

if (user != null)
    if (user.As<UserPart>().EmailStatus == UserStatus.Pending)
        var siteUrl = _orchardServices.WorkContext.CurrentSite.BaseUrl;
        if (String.IsNullOrWhiteSpace(siteUrl))
            siteUrl = HttpContext.Request.ToRootUrlString();

        _userService.SendChallengeEmail(user.As<UserPart>(), nonce => Url.MakeAbsolute(Url.Action("ChallengeEmail", "Account", new { Area = "Orchard.Users", nonce = nonce }), siteUrl));

        return RedirectToAction("ChallengeEmailSent");

    if (user.As<UserPart>().RegistrationStatus == UserStatus.Pending)
        return RedirectToAction("RegistrationPending");

    _authenticationService.SignIn(user, false /* createPersistentCookie */);

    return this.RedirectLocal(returnUrl);

ModelState.AddModelError("_FORM", T(ErrorCodeToString(/*createStatus*/MembershipCreateStatus.ProviderError)));

// If we got this far, something failed, redisplay form
var shape = _orchardServices.New.Register();
return new ShapeResult(this, shape);
Feb 27, 2015 at 8:46 AM
Edited Feb 27, 2015 at 8:47 AM
Could you point out where exactly you are setting the additional fields on the created user? I don't see it.
Feb 27, 2015 at 10:09 AM
I am setting the additional fields in this line:

var user = _membershipService.CreateUser(new CreateUserParams(Title, City, Country, ZipPostalCode, userName, password, email, null, null, false));

and when i debug my code .. i can see that the user is created. But when i see in my database i couldnot find the user in the DB
Feb 27, 2015 at 11:19 AM
Edited Feb 27, 2015 at 11:20 AM
You didn't show that code earlier.
Also, you are still not showing the code that is actually setting the properties on the user. I understand these are trivial things, such as implementing a migration step that extends the UserPartRecord with additional columns and all that, but it's impossible to say why your values aren't being stored in the database without looking at your code.

That being said, I think you're going about this the wrong way. Why are you changing core code instead of writing a custom part which you then attach to the User content type, for example as described in these posts?
The User type being a content type is meant to be extensible without requiring core code changes.
Mar 2, 2015 at 7:36 AM
Edited Mar 2, 2015 at 11:40 AM
Actually i am new to orchard cms and don't know much about it ... as far as i get it i am passing the values to this function:

var user = _membershipService.CreateUser(new CreateUserParams(Title, City, Country, ZipPostalCode, userName, password, email, null, null, false));

and here is the remaining code:

public CreateUserParams(string username, string Title, string City, string Country, string ZipPostalCode, string email, string password, string passwordQuestion, string passwordAnswer, bool isApproved)
        _username = username;
        _password = password;
        _email = email;
        _title = Title;
        _isApproved = isApproved;

i am working on orchard 1.8 and not on 1.9. So could you please guide me how could i achieve this by making changes in the core code
Mar 2, 2015 at 11:11 AM
I'm afraid I can't, sorry. I can, however, guide you into doing it the right way:
  1. Create your own module.
  2. Create a new content part, called something like ProfilePart and attach this to the User content type.
  3. Create a new controller that renders your registration page.
  4. Create a new IRouteProvider class that overrides the route mapped to the AccountController.Register controller action.
  5. Update your controller to handle the posted values and create a new User content item (using the IMembershipService) and "cast" it to your custom ProfilePart so you can set your additional values.
  6. Done.