Sending Formidable Forms Field Data To Airtable

This is a WordPress function that sends form data to a webhook URL using the WordPress HTTP API. It is hooked to the frm_after_create_entry action, which means that it will be executed after an entry is created in a form. The function takes two arguments: $entry_id, which is the ID of the entry that was just created, and $form_id, which is the ID of the form.

The function first retrieves the form data using the FrmEntry::getOne() function. Then it sets the webhook URL, the headers for the HTTP request, and the data to be sent to the webhook. The data is an array of field values, where the keys are the field names and the values are the form data. The data is then encoded as JSON and sent to the webhook using the wp_remote_post() function.

This function can be used to send form data from a WordPress site to a service like Airtable, which can be used to store and manage the data.

add_action( 'frm_after_create_entry', 'send_form_data_to_webhook', 20, 2 );
function send_form_data_to_webhook( $entry_id, $form_id ) {
  // Get the form data
  $form_data = FrmEntry::getOne( $entry_id, true );

  // Set the webhook URL
  $webhook_url = '';

  // Set the headers for the HTTP request
  $headers = array(
    'Content-Type' => 'application/json'

  // Set the data to be sent to the webhook
  $data = array(
    'fields' => array(
      // Set the field values here, using the form data
      // For example, if the form has a field with the name "Name", you can set the value like this:
      'Name' => $form_data->name,
      // Add additional fields as needed

  // Encode the data as JSON
  $json_data = json_encode( $data );

  // Send the HTTP request to the webhook
  $response = wp_remote_post( $webhook_url, array(
    'method' => 'POST',
    'headers' => $headers,
    'body' => $json_data
  ) );



Leave a Reply

Your email address will not be published. Required fields are marked *

This is an Advertorial

Learn how to build digital products without writing a single line of code

Build anything you can dream of without writing code or hiring a developer

Our non-technical students start companies using tools like Bubble, Softr , Elementor and Airtable. It’s easier, faster and more fun.

No matter what your background is, our lessons are designed to figure out what you don’t know and fill in the gaps

Join our learning community of soulmates, learn at your own pace and stay motivated to reach your objectives.

Begin Your No-Code Journey.

Training Mode : in-class
Location : E-349 Ikota Shopping Complex, VGC, Ajah, Lagos
Fees : N150,000