memreq
December 9, 2022, 9:47am
1
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 (createStatus == MembershipCreateStatus.Success)
{
newUser.IsApproved = true;
membership.UpdateUser(newUser);
//Add the user to the default group
if (!String.IsNullOrEmpty(request.DefaultGroup))
{
web.SiteGroups[request.DefaultGroup].AddUser(Utils.EncodeUsername(request.UserName.ToLower(), web.Site), request.UserEmail, request.FirstName + " " + request.LastName, "Self Registration");
//Login the user if selected
if (request.LoginCreatedUser)
{
Microsoft.SharePoint.IdentityModel.SPClaimsUtility.AuthenticateFormsUser(new Uri(web.Url), request.UserName, request.Password);
}
}
if (debuggingInfoItem != null)
{
if (debuggingInfoItem.Fields.ContainsField("LastError"))
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;
userItem.Update();
1 Like