Copied to clipboard

Flag this post as spam?

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


  • Brad Hunt 26 posts 57 karma points
    Jul 31, 2011 @ 05:34
    Brad Hunt
    0

    Add Member Properties via API in v4.7

    I have a simple user control that presents the user a form to complete. The code behind creates the member successfully, but I cannot populate the member extended properties that I created.

    I created a member type with properties like First Name, Last Name, etc.

    After I create the user, I am trying to set the properties in code:

    MembershipUser newUser= Membership.CreateUser(txtUsername.Text, txtPassword.Text, txtEmail.Text);
    var profile = System.Web.Profile.ProfileBase.Create(newUser.UserName);
    profile["firstName"] = txtFirst.Text;
    profile.Save();

    I have tried many variations on the above code, but the properties don't show up in the back end. The member is there, but the property is blank.

    I used this as a guide: http://www.aaron-powell.com/umbraco-members-profiles and wrote my own class, edited the web.config etc, but still I am not having success. In one thread Neils said this was not supported and should not be used. Can anyone confirm that 4.7 does not have a "built in" way to store extra user properties via code/api?

  • Richard Soeteman 4035 posts 12842 karma points MVP
    Aug 01, 2011 @ 05:00
    Richard Soeteman
    0

    Hi,

    In 4.5 they made the Member Methods, properties depecated and now edit member properties via the profile is the prefered way of doing things. However I think it is still easier to use the Methods on the Member class itself.

    Member member = Member.GetMemberFromLoginName( newUser.UserName);
    member.getProperty("your alias").Value = "some value;";
    member.Save();

    Hope this helps you,

    Richard

Please Sign in or register to post replies

Write your reply to:

Draft