Custom Select field added to Member Profile

I am attempting to add a select (dropdown) menu with two options to the member registration and profile views.

I have modified the class-ms-addon-profilefields.php file adding my new field:

Around line: 289 to the array of fields:

'digital_opt_out' => array(
					'label' => __( 'Digital Journal Access', 'membership2' ),
					'type' => MS_Helper_Html::INPUT_TYPE_SELECT,
					'field_options' => array('optIn'=>'Keep Access to Digital Journal','optOut'=>'Opt-Out of Access to Digital Journal'),
					'value' => array('optIn','optOut'),

and adding it to the 2nd area around line 255:

$Profile_Fields['digital_opt_out']['value'] = get_the_author_meta( 'digital_opt_out', $user->ID );

in my functions.php file I added the custom field and hooks to save it. This works when it's a normal input field.

add_action( 'show_user_profile', 'bga_extra_user_profile_fields' );
add_action( 'edit_user_profile', 'bga_extra_user_profile_fields' );
function bga_extra_user_profile_fields( $user ) {
  <h3><?php _e("Extra profile information", "blank"); ?></h3>
  <table class="form-table">
      <th><label for="digital_opt_out"><?php _e("Digital Journal Access"); ?></label></th>
      <span class="description"><?php _e("Opting out of recieving access to the digital journal will donate cost to the travel fund."); ?></span>
      <select name="digital_opt_out" id="digital_opt_out">
    		<option value="">Please select</option>
        <option value="optIn" <?php echo ( get_the_author_meta( 'digital_opt_out', $user->ID )  == 'optOut') ? ' selected ' : ''; ?>>Keep Access to Digital Journal</option>
        <option value="optOut" <?php echo ( get_the_author_meta( 'digital_opt_out', $user->ID ) == 'optOut') ? ' selected ' : ''; ?>>Opt-Out of Access to Digital Journal</option>

add_action( 'personal_options_update', 'bga_save_extra_user_profile_fields' );
add_action( 'edit_user_profile_update', 'bga_save_extra_user_profile_fields' );
function bga_save_extra_user_profile_fields( $user_id ) {
  $saved = false;
  if ( current_user_can( 'edit_user', $user_id ) ) {
    update_user_meta( $user_id, 'digital_opt_out', $_POST['digital_opt_out'] );
    $saved = true;
  return true;

However, when I try to make it a select field and populate the field_options etc. I get a select DOM object without any options.

I tried following the support on this URL:

but it seems to not be working for me. I'm not sure what i'm doing wrong. Also if there is a preferred place to put this modification vs. modifying the addon field.. i'm all ears. I couldn't find a good spot to hook into to make the modifications do to all the output buffering etc.

Any assitance would be greatly appreciated!

  • Vinod Dalvi

    Hi Carl,

    I hope you are well today and thank you for your question.

    Before answering your question i want to know why are you not using BuddyPress plugin and its User <a target="_blank" href="
    ">Extended Profiles module to achieve it which is easier way to achieve this.

    After installing BuddyPress plugin you have to just activate the "BuddyPress Integration" add-on of Memberships plugin to integrate both.

    Please advise.

    Kind Regards,
    Vinod Dalvi

  • Timothy Bowers

    Hey there,

    I just read your feedback on Vinod.

    seemed to scold me for not using buddy press and then has never seemed to check back in in over a day.

    I think it's more like a language barrier rather than scolding, but I just wanted to take a moment to apologise if that's how this came across, it certainly was not his intention.

    To answer your question, no you don't have to, but BuddyPress has this already built out. You don't need to use the additional stuff which you consider bloat.

    You should also avoid editing core files like class-ms-addon-profilefields.php, when updates occur, you lose changes.

    Is using the BP custom profile fields out of the equation?


  • Carl

    I'm open to using whatever gets the job done.

    After not hearing back I just dug in and made the change happen.

    I'm all for avoiding editing core files. I'd gladly revert my changes if there was a quick/easy way to add a new field. What would be the steps to do the BP custom profile fields?

    Do I install buddy press in total or is the custom profile fields a separate piece I can use without a full install?

  • Vinod Dalvi

    Hi Carl,

    I am really sorry if you think that i am forcing you to use BuddyPress but actually i wanted to tell you that it's very easy to add BuddyPress fields to the member / user profile.

    To use this feature just install and activate the BuddyPress plugin along with Memberships plugin by getting it from this page

    Then on the following path in the BuddyPress components settings just activate the "Extended Profiles" component deactivating all other components that you don't want to use as shown in the attached screenshot.

    Admin Area -> Settings -> BuddyPress -> Components

    And on the following path set the registration page as displayed in the second attached screenshot.

    Admin Area -> Settings -> BuddyPress -> Pages

    Activate the membership plugin add-on "BuddyPress Integration" on the following path to integrate the BuddyPress with membership plugin.

    Admin Area -> Membership 2 -> Add-ons

    Now you can just create the Profile Fields on the following path as described here

    Admin Area -> Users -> Profile Fields

    Please advise if you have more questions.

    Best Regards,
    Vinod Dalvi