Update member_type with custom_field data?

Hi, I’m very new to this and am struggling !!

I’m using S2member Pro with Buddypress. I have created a custom field on the registration form. When this field is filled in, I want the value to be saved in the buddypress member_type field. I have a plugin that then matches the member type to a WP role that I have set up.

The reason I am doing this is so if somebody registers as a Lender, then only the Lender profile group tabs are shown. If somebody registers as a Borrower, then only the Borrower profile group tabs are shown etc etc.

I’m sure this is probably a simple piece of code, but I don’t know where to start.

Thanks for your help !

I’m not a BuddyPress expert, but shouldn’t there be some built-in way to set the member_type with BuddyPress? You can use either s2Member or BuddyPress Profile Fields with s2Member. Please see this KBA: https://s2member.com/kb-article/buddypress-profile-fields-or-s2member-profile-fields/