Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hello,
I want to create a member in code like the following snippet.
Before execute the code, I'v had have to create a "WebsiteVisitor" MemberType and "BasicVisitor" MemberGroup in the backoffice.
MemberType mt = MemberType.GetByAlias("WebsiteVisitor");
MemberGroup memberGroup = MemberGroup.GetByName("BasicVisitor");
Member m = Member.MakeNew(userName, mt, new umbraco.BusinessLogic.User(0));
m.Password = password;
m.LoginName = userName;
m.Email = email.ToLower();
m.getProperty("fullName").Value = userName;
m.XmlGenerate(new System.Xml.XmlDocument());
//add the member in a group. m.AddGroup(memberGroup.Id);
m.Save();
My question is that could I create Membertype and MemberGroup in code.
I've searched lots of related articles, it's end up with no result. Hope someone can give me a sample. Thanks in advanced.
Hi Michael,
Try to use Services.MemberGroupService and Services.MemberTypeService.
https://our.umbraco.org/documentation/Reference/Management-v6/Services/MemberTypeService
Thanks, Alex
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Could I create MemberType ,MemberGroup in code?
Hello,
I want to create a member in code like the following snippet.
Before execute the code, I'v had have to create a "WebsiteVisitor" MemberType and "BasicVisitor" MemberGroup in the backoffice.
MemberType mt = MemberType.GetByAlias("WebsiteVisitor");
MemberGroup memberGroup = MemberGroup.GetByName("BasicVisitor");
Member m = Member.MakeNew(userName, mt, new umbraco.BusinessLogic.User(0));
m.Password = password;
m.LoginName = userName;
m.Email = email.ToLower();
m.getProperty("fullName").Value = userName;
m.XmlGenerate(new System.Xml.XmlDocument());
//add the member in a group. m.AddGroup(memberGroup.Id);
m.Save();
My question is that could I create Membertype and MemberGroup in code.
I've searched lots of related articles, it's end up with no result. Hope someone can give me a sample. Thanks in advanced.
Hi Michael,
Try to use Services.MemberGroupService and Services.MemberTypeService.
https://our.umbraco.org/documentation/Reference/Management-v6/Services/MemberTypeService
Thanks, Alex
is working on a reply...