Support

Account

Home Forums General Issues Populating custom Input Field values from custom database values Reply To: Populating custom Input Field values from custom database values

  • okay so I got the values to populate using the code below

    function populate_phone($field) {
      global $wpdb; //use wp database
      $field['value'] = 'N/A'; //default value
      $current_user_id = get_current_user_id(); //get logged in user's id
      $wp_custom_user_info = $wpdb->get_results("
        SELECT * FROM custom_table 
        WHERE wp_user=" . $current_user_id
      );
      $field['value'] = $wp_custom_user_info[0]->phone_numbers;
      
      return $field;
    }
     add_filter('acf/load_field/name=phone', 'populate_phone');

    My other question still stands: How do I update that value after pressing “Save/Update” button?