Created
June 9, 2025 03:17
-
-
Save SitesByYogi/b7d9ed1a9d991b95702f200b7495ff30 to your computer and use it in GitHub Desktop.
Airtable webhook template
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) { | |
// Target only one form | |
if ($form_data['id'] != 123) return; // Change 123 to your form ID | |
$airtable_token = 'YOUR_AIRTABLE_TOKEN'; | |
$base_id = 'YOUR_BASE_ID'; | |
$table_name = 'YOUR_TABLE_NAME'; | |
// Map WPForms fields to Airtable fields | |
$mapped_fields = array( | |
'Name' => $fields[1]['value'], // Replace 1 with actual field ID | |
'Email' => $fields[2]['value'], | |
'Message' => $fields[3]['value'], | |
); | |
$body = array( | |
'records' => array( | |
array( | |
'fields' => $mapped_fields | |
) | |
) | |
); | |
$response = wp_remote_post("https://api.airtable.com/v0/{$base_id}/{$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