Registration problem - custom data fields not saved
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
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"
/>
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.
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"
);