Copied to clipboard

Flag this post as spam?

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


  • Sebastiaan Janssen 5045 posts 15477 karma points MVP admin hq
    Sep 03, 2009 @ 18:02
    Sebastiaan Janssen
    0

    Creating members with custom properties

    I'm trying to use the MemberShipProvider exclusively to create new members. It is my understanding that the ProfileProvider has also been implemented in the latest versions of Umbraco, so this should not be very difficult.

    I want to add extra fields to the registration page, for example: "Last name". 

    The membership provider in my web.config is set to:

        <membership defaultProvider="UmbracoMembershipProvider" userIsOnlineTimeWindow="15">
          <providers>
            <clear />
            <add name="UmbracoMembershipProvider" type="umbraco.providers.members.UmbracoMembershipProvider" enablePasswordRetrieval="true" enablePasswordReset="true" requiresQuestionAndAnswer="false" defaultMemberTypeAlias="member" />
          </providers>
        </membership>

    And I've added an extra section under that for the profile values:

        <profile enabled="true">
          <properties>
            <add name="lastname"/>
          </properties>
        </profile>

    After reading this article, it sounds as if I can very easily save the profile information, the "create user" template looks like this:

    <%@ Master Language="C#" MasterPageFile="/masterpages/Master.master" AutoEventWireup="true" %>
    
    <script Langauge="C#" runat="server">
        protected void CreatedUser(Object sender, EventArgs e) 
        {
                /* User is created and setting extra parameters to profile */
            TextBox lastname= (TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("lastname");
                Profile.lastname = lastname.Text;
        }
    </script>
    
    <asp:content ContentPlaceHolderId="body" runat="server">
    <form runat="server">
    <asp:CreateUserWizard ID="CreateUserWizard1" OnCreatedUser="CreatedUser" runat="server">
        <WizardSteps>
            <asp:CreateUserWizardStep ID="CreateUserWizardStep1" runat="server">
            <ContentTemplate>     
                <asp:TextBox Runat="server" ID="lastname"></asp:TextBox><br />
                <asp:TextBox Runat="server" ID="username"></asp:TextBox><br />
                <asp:TextBox Runat="server" ID="password"></asp:TextBox><br />
                <asp:TextBox Runat="server" ID="email"></asp:TextBox><br />
            </ContentTemplate>
            </asp:CreateUserWizardStep>
    
            <asp:CompleteWizardStep ID="CompleteWizardStep1" runat="server">
            </asp:CompleteWizardStep>
        </WizardSteps>
    </asp:CreateUserWizard>
    </form>
    </asp:content>

    So as soon as the user has been created the Profile.lastname value should be set. 

    I get a nice message saying that a new member has been created, but when I look in the backoffice, it has not saved the "lastname" property.
    I checked the casing of the "lastname" alias on my member type properties, it is all lower case so that should not be a problem. Besides, I get no errors anywhere.

    So... Who's tried using the profile provider and has succeeded? I know I can do it the manual way, but the whole point of the membership provider is that I shouldn't have to go through the umbraco API any more.

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Sep 03, 2009 @ 19:39
    Dirk De Grave
    1

    Sebastiaan, not sure if Aaron's post is of any relevance to you... but here's the pointer to his blog post about membership, profile provider stuff

    I haven't been into that much details (as in "haven't implemented it") but would love to know if you can get it to work...

     

    Cheers,

    /Dirk

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Sep 03, 2009 @ 19:42
    Dirk De Grave
    0

    I'd think you can use profile data when member has been created...and you'll have to set the values first... in the CreatedUser event... but I could be completely wrong of course... Correct if I am!

     

    Cheers,

    /Dirk

  • Morten Bock 1867 posts 2140 karma points MVP 2x admin c-trib
    Sep 03, 2009 @ 20:18
    Morten Bock
    1

    I have not tried it either, but you may need to set the provider explicitly:

    <profile defaultProvider="UmbracoMemberProfileProvider" enabled="true">
      <providers>
          <clear />
          <add name="UmbracoMemberProfileProvider" type="umbraco.providers.members.UmbracoProfileProvider, umbraco.providers" />
      </providers>
      <properties>
          <add name="lastname" provider="UmbracoMemberProfileProvider"/>
      </properties>
    </profile>

    Try it out :-)

  • Sebastiaan Janssen 5045 posts 15477 karma points MVP admin hq
    Sep 04, 2009 @ 11:12
    Sebastiaan Janssen
    0

    Thanks Dirk & Morten, I am a few big steps further along now. 

    Created a class like in Aaron's blog post, in my master page I actually get firstname, lastname and middlename as autocompletion for "Profile.".

    So you'd think it would work.... Think again, nothing seems to be saved to the database.

    Also, how do I get rid of this code in my masterpage, I'm not sure how I can seperate it out. I tried making a class in my new Member project, but obviously, it doesn't know what CreateUserWizard1 is, not that there is a Profile.lastname property (for example).
    Should I also move the masterpage to the member project and have the postbuild copy it to the website? 

  • Sebastiaan Janssen 5045 posts 15477 karma points MVP admin hq
    Sep 04, 2009 @ 12:47
    Sebastiaan Janssen
    0

    I was hoping that this would just link up the profile properties to the umbraco member properties, but there's still some programming involved.

    Also, realistically, how often am I going to be changing the membership provider in my running website? ;-)

    So for now, I might as well do it the old-fashioned way and target the umbraco API directly, until I have some time to investigate this further.

  • Matt Taylor 873 posts 2086 karma points
    May 10, 2011 @ 12:52
    Matt Taylor
    0

    Hi Sebastian,

    Did you ever get this working?

    I'm using V4.7 now and having the same trouble getting the extra fields saved for the member in Umbraco.

    Regards,

    Matt

    -------

    Solved my problem, http://our.umbraco.org/forum/developers/api-questions/12348-member-profile-problem-45x?p=0#comment76619

Please Sign in or register to post replies

Write your reply to:

Draft