Custom field stays empty

Hi Chris,

I managed to add new custom field for FBA, using web.SiteUserInfoList.GetItemById(user.ID)
But when creating new user the field stays empty, so maybe it is not init correctly?

I did not put the the variable in MembershipRequest.cs, line 526:

request.Custom = user.Custom;

because it will not find the user.Object.

But I referenced the field in MembershipReviewHandler.cs:

request.Custom = item[MembershipReviewListFields.CUSTOM].ToString();

Did I forget anything?

In the FBA Pack we don’t have any custom fields, and all of the fields we have are sent to SharePoint with the AddUser Call.

If you want to set custom fields, you’ll have to first add the field’s to the user’s SharePoint profile, and then set them when the user is created:

web.SiteGroups[request.DefaultGroup].AddUser(loginName, request.UserEmail, request.FirstName + " " + request.LastName, "Self Registration");
                            //Save custom information
                            SPUser user = web.AllUsers[loginName];

                            SPListItem userItem = web.SiteUserInfoList.GetItemById(user.ID);

                            userItem["Custom"] = request.Custom;
1 Like