Copied to clipboard

Flag this post as spam?

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


  • Jeremy 2 posts 22 karma points
    Aug 06, 2010 @ 23:44
    Jeremy
    0

    Dynamically creating new members in Umbraco 4.5

    Hi,

     

    I am trying to dynamically create new members with an asp .net CreateUserWizard user control in Umbraco 4.5.  The problem I have is that I am unable to save the custom property values that I had added to my member type.  It does save the username, email address, and password correctly.

     

    I noticed that the Member.MakeNew method is obsolete.  It says to use the System.Web.Security.Membership.CreateUser.  If I use this method, how do I set the values for my custom property values of my member type?

     

    Thanks

     

        Protected Sub CreateUserWizard1_CreatedUser(ByVal sender As Object, ByVal e As EventArgs) Handles CreateUserWizard1.CreatedUser
            Dim lMemberType As MemberType
            Dim lNewMember As Member

            If (Membership.GetUserNameByEmail(CreateUserWizard1.Email) Is Nothing) Then
                lMemberType = MemberType.GetByAlias("RegisteredUser")

                lNewMember = Member.MakeNew(CreateUserWizard1.UserName, lMemberType, New BusinessLogic.User(0))

                'lNewMember = Membership.CreateUser(CreateUserWizard1.UserName, CreateUserWizard1.Password, CreateUserWizard1.Email)

                lNewMember.Email = CreateUserWizard1.Email
                lNewMember.Password = CreateUserWizard1.Password
                lNewMember.LoginName = CreateUserWizard1.UserName

                Dim lFirstName As cms.businesslogic.property.Property = lNewMember.getProperty("fname")
                Dim lFirstNameTextBox As TextBox = CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("FirstName"), TextBox)
                lFirstName.Value = lFirstNameTextBox.Text

                Dim lLastName As cms.businesslogic.property.Property = lNewMember.getProperty("lname")
                Dim lLastNameTextBox As TextBox = CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("LastName"), TextBox)
                lLastName.Value = lLastNameTextBox.Text

                'lNewMember.getProperty("fname").Value = "Jeremy"
                'lNewMember.getProperty("lname").Value = "Vo"

                lNewMember.AddGroup(MemberGroup.GetByName("Registered Users").Id)

                lNewMember.Save()
            End If
        End Sub

  • bev0 39 posts 59 karma points
    Aug 07, 2010 @ 00:04
    bev0
    0

    good post, i also wanted to how to create new member in 4.5 myself. but i think all admins are probably asleep now due to diff timezone =)

    Lòng Dat Thóng

  • Arjan H. 226 posts 463 karma points c-trib
    Aug 07, 2010 @ 20:47
    Arjan H.
    0

    Unfortunately with Member.MakeNew being obsolete in v4.5 it's a bit more difficult to deal with custom properties. Here's one way of doing so:

    http://www.aaron-powell.com/umbraco-members-profiles

    I'd love to see someone come up with a simpler solution though. :$

  • Jeremy 2 posts 22 karma points
    Aug 09, 2010 @ 18:08
    Jeremy
    0

    Thanks for the reply.  The tags in the webconfig from the example does not match the webconfig in umbraco 4.5.1.  What are we missing?

Please Sign in or register to post replies

Write your reply to:

Draft