Creating an Umbraco Member using Membership.CreateUser(), and attaching member to a Member type
Hello all,
I am trying to create a new Umbraco Member from var member = Membership.CreateUser(Email.Text, Password.Text); and first of all I am getting the following errors when this code is being executed:
at umbraco.cms.businesslogic.Content.CreateContent(ContentType ct)
at umbraco.cms.businesslogic.member.Member.MakeNew(String Name, String LoginName, String Email, MemberType mbt, User u)
at umbraco.cms.businesslogic.member.Member.MakeNew(String Name, String Email, MemberType mbt, User u)
at System.Web.Security.Membership.CreateUser(String username, String password)
at HelloWorld.Registration.btnCreateUser_onclick(Object sender, EventArgs e) in C:\Users\ddore\Documents\Visual Studio 2010\Projects\HelloWorld\HelloWorld\Registration.ascx.cs:line 48
Object reference not set to an instance of an object.
I am not sure what the issue is, it seems that I cannot even create a member without an error. Secondly, once I am able to create this member, how do I connect the member type to it?
You need to set the defaultMemberTypeAlias to the Membertype you want to use on the UmbracoMembershipProvider section of your web.config file. Then it will work.
Thank you for your help Richard! My next question is: I have multiple custom properties that I am trying to assign to the new Member through the code behind. For instance, Address, Company, etc., which are all text boxes on the registration page. Is there any way that I can assign them in the code behind or are they meant to be assigned in the content management section only?
Creating an Umbraco Member using Membership.CreateUser(), and attaching member to a Member type
Hello all,
I am trying to create a new Umbraco Member from var member = Membership.CreateUser(Email.Text, Password.Text); and first of all I am getting the following errors when this code is being executed:
at umbraco.cms.businesslogic.Content.CreateContent(ContentType ct)
at umbraco.cms.businesslogic.member.Member.MakeNew(String Name, String LoginName, String Email, MemberType mbt, User u)
at umbraco.cms.businesslogic.member.Member.MakeNew(String Name, String Email, MemberType mbt, User u)
at umbraco.providers.members.UmbracoMembershipProvider.CreateUser(String username, String password, String email, String passwordQuestion, String passwordAnswer, Boolean isApproved, Object providerUserKey, MembershipCreateStatus& status)
at System.Web.Security.Membership.CreateUser(String username, String password, String email, String passwordQuestion, String passwordAnswer, Boolean isApproved, Object providerUserKey, MembershipCreateStatus& status)
at System.Web.Security.Membership.CreateUser(String username, String password)
at HelloWorld.Registration.btnCreateUser_onclick(Object sender, EventArgs e) in C:\Users\ddore\Documents\Visual Studio 2010\Projects\HelloWorld\HelloWorld\Registration.ascx.cs:line 48
Object reference not set to an instance of an object.
I am not sure what the issue is, it seems that I cannot even create a member without an error. Secondly, once I am able to create this member, how do I connect the member type to it?
Thanks in advance!
- Dom
HI Dominic,
You need to set the defaultMemberTypeAlias to the Membertype you want to use on the UmbracoMembershipProvider section of your web.config file. Then it will work.
Cheers,
Richard
Thank you for your help Richard! My next question is: I have multiple custom properties that I am trying to assign to the new Member through the code behind. For instance, Address, Company, etc., which are all text boxes on the registration page. Is there any way that I can assign them in the code behind or are they meant to be assigned in the content management section only?
Thanks in advance!
- Dom
Hi,
There are some other ways to do it, but I've been using the method described in this post and it works great (to access/update member properties): http://www.aaron-powell.com/umbraco-members-profiles
-Tom
Hi,
There is also another good example which might help you at http://umbraco.miketaylor.eu/2010/08/29/authenticating-new-members/
is working on a reply...