Copied to clipboard

Flag this post as spam?

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


  • Brendan Rice 538 posts 1102 karma points
    Jun 22, 2010 @ 14:01
    Brendan Rice
    0

    Create a member with custom MemberType properties

    Hi,

    I am trying to create a member with the following code.  What currently happens is that the member will be created in the database put an exception is thrown on the line [_member.getProperty("FirstName").Value = FirstName.Text;] as getProperty seems to return null.

    I have a FirstName property on the "Subscriber" member type in a Tab called personal details but for some reason this is not getting picked up by Umbraco.

    Thanks in advance,

    B

     

     

            public void Create()
            {
                MemberType memberType = MemberType.GetByAlias(MemberTypeConstants.Subscriber);
                MemberGroup memberGroup = MemberGroup.GetByName(MemberGroupConstants.RetirementSavingPlanner);

                _member = Member.MakeNew(EmailAddress.Text, memberType, new umbraco.BusinessLogic.User(0)); _member.Email = EmailAddress.Text;
               
                _member.Password = Password.Text;
                _member.LoginName = EmailAddress.Text;
               
                // Generate member Xml Cache
                _member.XmlGenerate(new System.Xml.XmlDocument());
                _member.getProperty("FirstName").Value = FirstName.Text;
                _member.getProperty("LastName").Value = LastName.Text;           

                _member.AddGroup(memberGroup.Id);

                _member.Save();

            }

  • Sebastiaan Janssen 5060 posts 15522 karma points MVP admin hq
    Jun 23, 2010 @ 02:05
    Sebastiaan Janssen
    0

    This seems legit code. Have a look at Tim's blogpost about creating members as well, might give you some clues. 

    The only problem I can think of right now is that the alias "FirstName" does not have the same casing as in Umbraco's backend, have you checked that?

  • Brendan Rice 538 posts 1102 karma points
    Jun 23, 2010 @ 15:44
    Brendan Rice
    0

    Turns out I was using the wrong case for the property it should have been camalCase.

    I had one of those head slap moments when I noticed this.

Please Sign in or register to post replies

Write your reply to:

Draft