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
    Feb 25, 2014 @ 17:57
    glenatron
    0

    Changing the MemberType of an existing Member

    I have a member who is created with one associated MemberType, but administrators need to be able to move them to a different MemberType without losing the user's credentials so just creating a new Member would - as far as I can tell - probably not work for this.

    I can do this:

    Member ourMember = Member.GetAllAsList().Where(x => x.Id == memberId).First();
    ourMember.ContentType = umbraco.cms.businesslogic.ContentType.GetByAlias(newMemberType);
    ourMember.Save();
    

    However, saving does not change the ContentType and the properties of the old contentType persist on the member while it exists. Presumably there is some different way of making this change? Otherwise is there a way to transfer the MembershipUser to a new Member without losing the login credentials?

    Also I can't help but feel that this way of getting a Member by Id is a terrible idea, but I couldn't see an easier one straight off.

  • Andy Butland 422 posts 2334 karma points MVP 4x hq c-trib
    Feb 27, 2014 @ 16:15
    Andy Butland
    1

    You can get a member by Id by using the constructor (it's a bit odd this way, one of the things that I understand a new API will do more sensibly):

    var member = new Member(memberId);

    However changing the type... I don't think you can (though the last confirmation of this I found was in 2005!, so I may be wrong on that).  I'm aware though that it was only with the new content API that changing the document type for a piece of content was available, and I suspect members and member types are analogous to this so may not be possible at present.

    Andy

Please Sign in or register to post replies

Write your reply to:

Draft