Copied to clipboard

Flag this post as spam?

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


  • glenatron 37 posts 132 karma points
    Mar 05, 2014 @ 13:03
    glenatron
    0

    Is it impossible to set the MemberType of a Member from code in 6.1.6?

    I am trying to create new Members using different MemberTypes on my Umbraco 6.1.6 site, but it seems determined to only create them with the default member type, regardless of whether I use the .Net or deprecated Umbraco way of doing things.

    This SO Question indicates that it is only possible to have one default MemberType and there is no way to create a Member of any different type through code, but that seems ridiculous.

    Ridiculous though it is, I can't find anything showing that it is wrong and - as usual - the Umbraco documentation confesses to being out of date and in need of updating. I'm using this as an alternative to changing the MemberType of an existing Member, which also appears to be against the rules.

    Is it actually impossible to create members of more than one type? If not, can anyone offer any guidance as to how to do it?

  • Andy Butland 422 posts 2334 karma points MVP 4x hq c-trib
    Mar 12, 2014 @ 09:20
    Andy Butland
    0

    Chaging a member type of an existing member I believe you are right, that's not supported.

    But I've not had any problems creating one of a particular type, using something like: 

    var mt = MemberType.GetByAlias("MyMemberType");
    var user = new User(0);  // admin user
    member = Member.MakeNew(name, loginName, email, mt, user);
    member.Save();
    member.XmlGenerate(new XmlDocument());
    Member.AddMemberToCache(member);
Please Sign in or register to post replies

Write your reply to:

Draft