1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Registration problem - custom data fields not saved

Registration problem - custom data fields not saved

4 posts, 0 answered
  1. Nick
    Nick avatar
    113 posts
    Registered:
    21 Oct 2008
    15 Nov 2011
    Link to this post
    I have set up a new user profile type (customer) and created my own registration template for the registration form which includes all the custom data fields. The form displays fine and allows me to complete and submit it.

    The user gets created, but only with the basic information - the custom data is not saved.

    I looked at the documentation (http://www.sitefinity.com/documentation/user-guide/displaying-content-using-widgets/users-widgets-group/configuring-the-registration-widget.aspx) and it says:

    "In Provider, which the user will be registered in... dropdown box, select where to register the user that is filling out the registration form.
    You can choose between Public users and Backend users."

    But I haven't got that option in the widget configuration options. I guess this is where it is going wrong and why the additional custom data isn't saving?

    Is this a bug or have I done something wrong?

    thanks
  2. Svetoslav Petsov
    Svetoslav Petsov avatar
    456 posts
    Registered:
    24 Sep 2012
    18 Nov 2011
    Link to this post
    Hi Nick,

     The option for the provider is only if you have multiple membership providers, which I suppose you don't have and that is why this option is not shown. You just created a new profile type. However, the reason for the values not saving may be that you didn't add the field inside the template correctly. Here's a sample of how to add a textfield to your template, so that it is properly wired to the custom field inside your profile type:

    <sitefinity:TextField runat="server" ID="testCustom"  DisplayMode="Write" DataItemType="Telerik.Sitefinity.Security.Model.SitefinityProfile" DataFieldName="testCustom"/>
    The name of my field here is "testCustom" and it is added in the basic profile. If you add the field to another profile type, you will have to change the DataItemType to the relevant Profile Type.  The DataFieldName property indicates to which field the value should be bound. Also, an ID is necessary to be added.
    Let me know if I can help you with something else.

    Kind regards,
    Svetoslav Petsov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Nick
    Nick avatar
    113 posts
    Registered:
    21 Oct 2008
    18 Nov 2011
    Link to this post
    Thanks. I'm sure I tried that correctly, guess not. In the end we ended up creating our own registration form as there were various other business requirements that couldn't be achieved through the default control.

    Now I'm presented with another issue:

    We need to find a user based on the content of one of the custom profile fields. I can't find any example code of how this could be achieved? So this question becomes:

    How can you query to get a user (or list of users) based on data in the custom profile?

    Edit: It's worth mentioning that I have done it using ORM to create my own model of the custom profile, but I was wondering (hoping) there would be something built in that would negate me having to do this.
  4. Svetoslav Petsov
    Svetoslav Petsov avatar
    456 posts
    Registered:
    24 Sep 2012
    21 Nov 2011
    Link to this post
    Hello Nick,

     You can first get all users, then iterate through them, get the profile of each one and then get the value of the custom field and check if it is the required one. I realize this is not an optimal method, but there is no other way by just making one query. Here's a sample code for that:

    UserManager mng = UserManager.GetManager();
                var users = mng.GetUsers().ToList();
                UserProfileManager profManager = UserProfileManager.GetManager();
                foreach (var item in users)
                {
                    var profile = profManager.GetUserProfile(item.Id, typeof(SitefinityProfile).FullName);
                    var value = DataExtensions.GetValue(profile, "customFieldName");
                     
                }

    You just need to change SitefinityProfile with the type of your custom profile type, then after you have the value perform a check and add the user to another list that would be the filtered one (or just remove it from the current).

    Kind regards,
    Svetoslav Petsov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
4 posts, 0 answered