• Guys, I’m going slightly mad ’cause I’m still struggeling with the own account tab thing. So please, I need your help…

    I’m using UM 2.0.25 free version with WP 4.9.8

    I’m looking for a solution to save a custom field on an extended account tab. The code I’ve found here doesn’t work properly: https://gist.github.com/champsupertramp/c1f6d83406e9e0425e9e98aaa36fed7d

    add_action('um_after_account_general', 'showUMExtraFields', 100);
    
    function showUMExtraFields() {
      $id = um_user('ID');
      $output = '';
      $names = array('phone_number', 'company');
    
      $fields = array(); 
      foreach( $names as $name )
        $fields[ $name ] = UM()->builtin()->get_specific_field( $name );
      $fields = apply_filters('um_account_secure_fields', $fields, $id);
      foreach( $fields as $key => $data )
        $output .= UM()->fields()->edit_field( $key, $data );
    
      echo $output;
    }
    
    add_action('um_account_pre_update_profile', 'getUMFormData', 100);
    
    function getUMFormData(){
      $id = um_user('ID');
      $names = array('phone_number', 'company');
    
      foreach( $names as $name )
        update_user_meta( $id, $name, $_POST[$name] );
    }

    After updating the custom field the meta_value is “0” or “1” but not the value of my custom field.

    So where is the mistake?

    Thanks a lot for help in advance!!

Viewing 3 replies - 1 through 3 (of 3 total)
  • I’ve got exactly the same problem.
    Seems like custom fields are not custom meta.
    Meaning update_user_meta() save on extra information that can be retrieve with get_user_meta()
    I’ve opened a topic to get the good information on how to save custom fields retrievable by using um_user(‘name_of_field’)
    Will post the answer when I’ll found it.
    Or if someone has it, please post it ?

    Found it.
    To save / update field value into profile account, you need to call update_profile from user class :

    
    global $ultimatemember;
    $user_id = um_user('ID');
        
    um_fetch_user($user_id);
    $toupdate[] = array('name_of_field' => 'its_value');
    UM()->user()->update_profile($toupdate);
    
    Thread Starter coxinha

    (@coxinha)

    Hi @wptechnology,

    thanks a lot for your reply and please excuse my late reply.

    Where should I enter your part in the code above?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Problems with saving custom field on extended account tab’ is closed to new replies.