SharePoint 2019 - Creating Custom Columns For The FBA Membership Request


#1

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.


#2

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:


#3

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.


#4

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();

#5

Thanks let me look into that.


#6

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,


#7

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.