Create Member Programatically using asp.net membership??
Hi All,
I know how to make members using the old ways but just wondering how I'd do this using the new asp.net membership stuff where I can assign a member type/group??
I would still go for the old depricated way, much easier member.getProperty("the alias here").value = .
If you want to use the asp.net way you can assign properties using the role provider as described in this blog post from Aaron however it would require some configuration.
However, when I try to login with the newly created member account, using the Asp.Net Login Control, I get a 'Your login attempt was unsuccesful' message
Is it not possible to use the Asp.Net Login Control with the Member.MakeNew() method?
Create Member Programatically using asp.net membership??
Hi All,
I know how to make members using the old ways but just wondering how I'd do this using the new asp.net membership stuff where I can assign a member type/group??
MemberType memberType = MemberType.GetByAlias("publicMember");
Member m = Member.MakeNew(name, username, email, memberType, new umbraco.BusinessLogic.User(0));
m.Save();
Roles.AddUserToRole(username, groupNode.InnerText);
MemberType memberType = MemberType.GetByAlias("publicMember");
Member m = Member.MakeNew(name, username, email, memberType, new umbraco.BusinessLogic.User(0));
m.Save();
umbraco.library.RefreshContent();
Roles.AddUserToRole(m.LoginName, "Public");
I tried this as well just to create a member.. the only problem is that when umbraco gets in to the method and tries:
foreach (string username in usernames) {
Member m = Member.GetMemberFromLoginName(username);
foreach (int roleId in roles)
m.AddGroup(roleId);
}
Member.GetMemberFromLoginName returns null... any idea why that is???
Tom,
Can use Membership.CreateUser(username, password, email) and you're good to go. Also make sure to catch any exceptions that may arise...
Hope this helps.
Regards,
/Dirk
Thanks for the reply Dirk!
but then how would i set custom properties on that member type?
i.e. say my member has a date of birth property?
I would still go for the old depricated way, much easier member.getProperty("the alias here").value = .
If you want to use the asp.net way you can assign properties using the role provider as described in this blog post from Aaron however it would require some configuration.
Cheers,
Richard
Hi Richard,
Because I don't know how to create a new member and set it's member type, I reverted to the deprecated way:
However, when I try to login with the newly created member account, using the Asp.Net Login Control, I get a 'Your login attempt was unsuccesful' message
Is it not possible to use the Asp.Net Login Control with the Member.MakeNew() method?
Greetings,
Anthony
HI Anthony,
Yes but I think you forgot to set a password on the membertype.
member.Password="SomePass";
Hope this helps,
Richard
Hi Richard,
Thanks a lot, it worked :)
is working on a reply...