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

  • Solved it. If anyone ever needs this here you go. My main issue was that instead of using $_POST[‘acf’][‘field_5da4981a6418e’] I used $_POST[‘acf’][‘phone_numbers’] so it wasn’t storing the values but storing NULL.

    function update_phone() {
      global $wpdb;
      $current_user_id = get_current_user_id();
    
      $new_value = $_POST['acf']['field_5da4981a6418e'];
    
      $wpdb->update(
        "custom_table",
        array(
          "phone_numbers" => $new_value,
        ),
        array( 
          'wp_user' =>  $current_user_id,
        ),
        array( 
          '%s',
        ),
        array( '%s' )
      );
    }
    add_action('acf/save_post', 'update_phone', 1);