This project is read-only.

IMembershipService.CreateUser does not update data

Topics: Writing modules
Apr 23, 2012 at 4:48 PM


I want to create a extend user from UserPartRecord.

I have a error: Let review my code.

// create user of orchard
var user = _membershipService.CreateUser(new CreateUserParams(createModel.UserName, createModel.Password, createModel.Email, null, null, true));
dynamic model = Services.ContentManager.UpdateEditor(user.ContentItem, this);

// create customer


When excute  

var user = _membershipService.CreateUser(new CreateUserParams(createModel.UserName, createModel.Password, createModel.Email, null, null, true));

A user have been created. But it has not been stored in database.
If I remove  the line
data will be store.

Please give me some advices,

Apr 23, 2012 at 5:02 PM

Having absolutely no clue what CreateCustomer is doing, I don't think one can guess.

Apr 23, 2012 at 6:07 PM

I found this error.

After it excute the funtion _membershipService.CreateUser, the real data is not yet created in database. The function CreateCustomer try to find the newest user to create model Customer. So it throw a error.

Do you have any solutions to create real data after excute the function CreateUser ?

Apr 23, 2012 at 6:20 PM
Edited Apr 23, 2012 at 6:20 PM

Why don't you just pass in the created 'user' into your 'CreateCustomer' method? That way, you don't need to look for the newest user (which is probably a bad idea anyway, as in between requests, another user could have been created).

Apr 24, 2012 at 1:00 AM

I know that.

The scenario is customization standard user of orchard.

This is Customer model:

public class Customer
        public virtual int Id { get; set; }
        public virtual string FirstName { get; set; }
        public virtual string LastName {get; set;}
        public virtual string PhoneNumber {get; set;}
        public virtual string PhoneNumberExtentions { get; set; }

        public virtual UserPartRecord UserPartRecord { get; set; }

        public virtual IEnumerable<Job> Jobs { get; set; }

Currently, I create user by funtion _membershipService.CreateUser then get ID (UserPardRecord) to create customer.

I just wanted to know the way to create real data in database after it excute funtion _membershipService.CreateUser.


Apr 24, 2012 at 1:14 AM

Don't do that. Users are content items for a reason: so that you can extend them by composition, like everything else in Orchard. Add parts instead.

Apr 24, 2012 at 7:58 AM

Our system need 2 user types: Customer and Courier.

Wich user type, it has another informations.

Can we extend user standar to resolve that?

Please give me more explanation!


Apr 24, 2012 at 8:30 AM

Sure. You could have a part that has a property that holds the info whether it's a customer or courier, and/or you could attach one part or the other from a handler depending on the type of user, etc.

Apr 25, 2012 at 1:59 AM

I'll try it.