Registration problem - custom data fields not saved

Posted by Community Admin on 04-Aug-2018 15:14

Registration problem - custom data fields not saved

All Replies

Posted by Community Admin on 15-Nov-2011 00:00

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

Posted by Community Admin on 18-Nov-2011 00:00

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

Posted by Community Admin on 18-Nov-2011 00:00

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.

Posted by Community Admin on 21-Nov-2011 00:00

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

This thread is closed