Last active
          June 18, 2025 13:32 
        
      - 
      
- 
        Save SitesByYogi/b7d9ed1a9d991b95702f200b7495ff30 to your computer and use it in GitHub Desktop. 
    Airtable webhook template for America's Thrift
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | <?php | |
| add_action('wpforms_process_complete', 'send_wpforms_to_airtable', 10, 4); | |
| function send_wpforms_to_airtable($fields, $entry, $form_data, $entry_id) { | |
| // Only target your specific form | |
| if ($form_data['id'] != 123) return; // Replace 123 with your actual WPForms form ID | |
| $airtable_token = 'patd5lt9ek7eUOC2s.68b1bfd99b7031cf84499cd72f4115cebfa880b7d08b91a8a4d7ef7814b87cad'; | |
| $base_id = 'appD5ekRSKu5U7oW8'; | |
| $table_name = 'Active Donation Drives'; | |
| // Map WPForms fields to Airtable fields | |
| $mapped_fields = array( | |
| 'Contact First Name' => $fields[1]['value'], // Replace with actual WPForms field IDs | |
| 'Contact Last Name' => $fields[2]['value'], | |
| 'Ph # (Must have)' => $fields[3]['value'], | |
| 'Contact Email' => $fields[4]['value'], | |
| 'Organization Name' => $fields[5]['value'], | |
| 'Location Address' => $fields[6]['value'], | |
| 'Number of Participants' => $fields[7]['value'], | |
| 'Drive Start Date' => $fields[8]['value'], | |
| 'Drive End Date' => $fields[9]['value'], | |
| 'Comments' => $fields[10]['value'], | |
| ); | |
| $body = array( | |
| 'records' => array( | |
| array( | |
| 'fields' => $mapped_fields | |
| ) | |
| ) | |
| ); | |
| $response = wp_remote_post("https://api.airtable.com/v0/{$base_id}/" . rawurlencode($table_name), array( | |
| 'method' => 'POST', | |
| 'headers' => array( | |
| 'Authorization' => 'Bearer ' . $airtable_token, | |
| 'Content-Type' => 'application/json', | |
| ), | |
| 'body' => json_encode($body), | |
| )); | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment