• Resolved mobnew

    (@mobnew)


    I added custom fields to the Account tab that correspond to the additional information we capture during the registration process. On submit the new fields update the database successfully. However, I am struggling with loading the current information in the fields when users visit their account page.

    For instance, we capture a Company Name during registration. I have added a text input field to the account tab that successfully updates the meta_value for that key when the form is submitted. I would like the field to be populated with the current Company name when the page loads. Any help would be greatly appreciated. Here is my current code:

    add_action('um_after_account_general', 'um_account_tab_add');
    function um_account_tab_add( ) {
    		?>
    
            <div class="um-field um-field-company" data-key="company">
              <div class="um-field-label">
                <label for="company">Company</label>
                <div class="um-clear"></div>
              </div>
              <div class="um-field-area">
                <input class="um-form-field valid " type="text" name="company" id="company"  placeholder="" data-validate data-key="company">
              </div>
            </div>
    <?php
    
    }

    Thank you

    https://www.ads-software.com/plugins/ultimate-member/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter mobnew

    (@mobnew)

    I would have to guess there is a better way, but for now I have found adding the following to the start of the above function works:

    global $wpdb;
    $user_ID = get_current_user_id();
    
    $company = $wpdb->get_row("SELECT * from wp_usermeta WHERE user_id='".$user_ID."' AND meta_key='company'");

    And then adding value=”<?=$company->meta-value ?>” to the input.

    If there is a better or more efficient way to complete this, please let me know.

    Thank you,

    Plugin Author Ultimate Member

    (@ultimatemember)

    Try get_user_meta( $user_id, ‘field_key_here’, true );

    Thanks

    Thread Starter mobnew

    (@mobnew)

    Thank you. Much appreciated.

    Plugin Author Ultimate Member

    (@ultimatemember)

    You’re welcome.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Populate custom fields on account page’ is closed to new replies.