Copied to clipboard

Flag this post as spam?

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


  • Craig O'Mahony 364 posts 918 karma points
    Nov 07, 2012 @ 17:23
    Craig O'Mahony
    0

    Programmatically change a members Name, Login and Password

    Hi I'm creating a batch of members from an SQL Recordset using the following:

    //Assign the standard Member Type
    MemberType mytype = MemberType.GetByAlias("WebsiteUser");
    //Create the Member
     Member myNewMember = Member.MakeNew(myMemberRow["loginname"].ToString(),myMemberRow["email_address"].ToString(), mytype, new umbraco.BusinessLogic.User(3));
    //Assign the standard Member Group (role)
    MemberGroup myGroup = MemberGroup.GetByName("Standard");
    myNewMember.AddGroup(myGroup.Id);

    I'm then getting and assigning the values of the properties (one's that I've created) such as:

    myNewMember.getProperty("firstName").Value = myMemberRow["fname"].ToString() ;
    myNewMember.getProperty("lastName").Value = myMemberRow["lname"].ToString() ;


    But I can't seem to be able to 'get' or set the values for the Name, Login and Password. Doe's anybody know the syntax that I should be using? Whenever I try something like:

    myNewMember.getProperty("login").Value = myMemberRow["loginname"].ToString() ;

    I get an error of Object Reference not set to an instance of an object, which seems to suggest that the property isn't called what I think it's called!

    Any help would be gratefully received :)

    Thanks,

    Craig

  • Craig O'Mahony 364 posts 918 karma points
    Nov 07, 2012 @ 19:32
    Craig O'Mahony
    0

    Hi turns out that I'm a bit of a dingbat!

    Using MembermyNewMember=Member.MakeNew(myMemberRow["loginname"].ToString(),myMemberRow["email_address"].ToString exposes the 'standard' properties of the member object! So I can just use 

    myNewMember.Password = "mypassword" (or whatever).

    Just thought that I'd post this just in case someone else confuses themselves into oblivion!!

    Craig

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies