SharePoint 2019 - Creating Custom Columns For The FBA Membership Request

Hello,

I have an issue that I need assistance with. I want to add more columns to the membership request web part like address, a drop down for license category and company name. I was able to create the fields in visual studio but I’m not sure which backend file I need to edit so that these are submitted to the database. Also do I need to create these additional columns in the database or they are just added automatically when I create the solution. If possible, is there a step by step approach for achieving this.

Thank you.

Usually when I make field customizations they are only for SharePoint, so instead of saving them back to the membership database I save them to the user’s profile in SharePoint. If you do want to store the profile properties in the membership database, take a look at the Profile Provider:

Ok. Thank so much for the response. I am new developer in SharePoint so I only thought that new columns can be created only on the database.

So if I am to save the profiles in SharePoint. How best can I achieve that, and will that still link with data in the membership database.

Thank You.

Regards.

Here’s some sample code for updating the user profile for an SPUser:

spuser.Email = txtEmail.Text;
spuser.Name = txtFullName.Text;

spuser.Update();

SPListItem userItem = this.Web.SiteUserInfoList.GetItemById(spuser.ID);

userItem["City"] = txtCity.Text;
userItem["State"] = txtState.Text;


userItem.Update();

Thanks let me look into that.

Hi again,

Sorry to continue asking questions on this topic, but I have a few issues that I would be really grateful if you give me more clarity on. So I have added a control “Address” on the webpart. I am trying to follow step by step for adding the backend code using an exiting column “FirstName”. My issue is that within the MembershipRequest.cs where do I exactly add the code to update the “Address” field in the SharePoint User Profile List is it within the ApproveMemberShip() method.

My sample code looks like below:

        SPUser sPUser = web.EnsureUser(request.UserName);
        SPListItem userItem = web.SiteUserInfoList.GetItemById(sPUser.ID);
        userItem["Address"] = request.Address;
        userItem.Update();

I tried inserting it below this line but nothing happened

newUser = membership.CreateUser(request.UserName, request.Password, request.UserEmail, null, null, true, null, out createStatus);

Regards,

You’re going to want to add it everywhere in the code that the spuser gets updated. To make sure it’s actually running properly, you can try to run it in debug mode. Or maybe add a temporary button to the webpart and have it write some messages to the screen to ensure that your code is being run.

Hi ccoulson,

i would like to add new fields in FBA user management form for my SP2019 site, can you share me the code to pass the parameters to below methos.
Utils.BaseMembershipProvider().CreateUser(txtUsername.Text, txtPassword.Text, txtEmail.Text, txtQuestion.Text, txtAnswer.Text, isActive.Checked, null, out createStatus);

i am new to sharepoint, so please share the code and process step by step clearly

The membership provider’s createuser function doesn’t allow for extra fields to be added, so you have to store them elsewhere, like in the SharePoint user profile using the code listed above.

If you want to know how to call CreateUser, the actual code for the FBA Pack is available on Github. You can see the specific line here: