Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Michael 22 posts 61 karma points
    Jun 11, 2015 @ 03:10
    Michael
    0

    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.

  • Alex Skrypnyk 6163 posts 24143 karma points MVP 8x admin c-trib
    Jun 11, 2015 @ 09:15
    Alex Skrypnyk
    100

    Hi Michael,

    Try to use Services.MemberGroupService and Services.MemberTypeService.

    https://our.umbraco.org/documentation/Reference/Management-v6/Services/MemberTypeService

    Thanks, Alex

Please Sign in or register to post replies

Write your reply to:

Draft