Is a default password set for Members created via: Member.MakeNew()
If i create a new member via the MakeNew() method is a password generated by the system or do I need to then call the ChangePassword() method to set the password.
Example:
public void RegisterMember(string username, string memberType)
{
var type = MemberType.GetByAlias(memberType);
var member = Member.MakeNew(username, type, new umbraco.BusinessLogic.User(0));
member.Save();
}
or
public void RegisterMember(string username, string password string memberType)
{
var type = MemberType.GetByAlias(memberType);
var member = Member.MakeNew(username, type, new umbraco.BusinessLogic.User(0));
member.Save();
member.ChangePassword(password);
}
Also what is the most efficient way of creating a new member with a password that the member has specified during registration.
Just been checking the code for v4.1, and doesn't set the password upon MakeNew(). But, you should really use the memership functions to create a member. Check this wiki page for more info.
1. How can I set the memberType of a user created via the membership provider?
2. How can I set properties of the newly created member.
Do I need to create the user via the Membership.CreateUser() method and then get the created user via Member.GetMemberFromEmail() and set the properties etc there. Or can I cast from System.Web.Security.MembershipUser to umbraco.cms.businesslogic.member.Member?
1/ You don't. umbraco's membership implementation does take care of that for you. All you need to do is to specify the attribute on the membership provider, just as you did before.
2/ CreateUser() returns a MembershipUser, which you can (down)cast to a umbraco member. Ok, you got me there. You'll have to rely on the member api there to set/update properties on the member object (unless for generic properties such as Email, UserName, etc... as specified here).
Is a default password set for Members created via: Member.MakeNew()
If i create a new member via the MakeNew() method is a password generated by the system or do I need to then call the ChangePassword() method to set the password.
Example:
or
Also what is the most efficient way of creating a new member with a password that the member has specified during registration.
Thanks
Tim
Tim,
Just been checking the code for v4.1, and doesn't set the password upon MakeNew(). But, you should really use the memership functions to create a member. Check this wiki page for more info.
Cheers,
/Dirk
Hi Dirk,
Thanks for the link to the documentation.
Just a couple of quick questions:
1. How can I set the memberType of a user created via the membership provider?
2. How can I set properties of the newly created member.
Do I need to create the user via the Membership.CreateUser() method and then get the created user via Member.GetMemberFromEmail() and set the properties etc there. Or can I cast from System.Web.Security.MembershipUser to umbraco.cms.businesslogic.member.Member?
Tim
Hi Tim,
1/ You don't. umbraco's membership implementation does take care of that for you. All you need to do is to specify the attribute on the membership provider, just as you did before.
2/ CreateUser() returns a MembershipUser, which you can (down)cast to a umbraco member. Ok, you got me there. You'll have to rely on the member api there to set/update properties on the member object (unless for generic properties such as Email, UserName, etc... as specified here).
Hope this helps.
Regards,
/Dirk
You should use Membership Profiles - http://www.aaron-powell.com/blog/july-2009/umbraco-member-profiles.aspx
is working on a reply...