DEV Community

Rahul Sharma
Rahul Sharma

Posted on

How to Send CF7 Submissions to Multiple APIs at the Same Time (Without Zapier)

Most CF7 integration tutorials assume a one-to-one relationship: one form, one destination. But real business workflows rarely work that way.

A typical agency client might need a single contact form submission to go to three places simultaneously: their CRM (HubSpot or Salesforce), their email marketing platform (Mailchimp or Brevo), and a shared Google Sheet for the ops team. Setting this up with dedicated single-destination plugins means installing three separate plugins, managing three separate authentication flows, and hoping none of them conflict.

The common workaround is Zapier. CF7 fires a webhook to Zapier, and Zapier distributes it to multiple destinations. This works but adds cost (per-task pricing scales quickly), adds a dependency (Zapier outage = broken integration), and adds latency (the Zapier relay introduces delay between form submit and CRM update).

There is a cleaner way to do this entirely inside WordPress.

How Multi-API Routing Works Without Middleware

When a CF7 form submits, WordPress fires the wpcf7_before_send_mail hook. Any number of functions can be registered to this hook. Each function runs in sequence during the same PHP request.

This means you can make multiple outbound API calls from a single form submission — each to a different endpoint, with different authentication, different payload structures — all within the same server-side execution:

add_action('wpcf7_before_send_mail', 'cf7_send_to_hubspot');
add_action('wpcf7_before_send_mail', 'cf7_send_to_mailchimp');
add_action('wpcf7_before_send_mail', 'cf7_send_to_google_sheets');

function cf7_send_to_hubspot($contact_form) {
    if ((int) $contact_form->id() !== YOUR_FORM_ID) return;

    $submission = WPCF7_Submission::get_instance();
    $data       = $submission->get_posted_data();

    wp_remote_post('https://api.hubapi.com/crm/v3/objects/contacts', [
        'headers' => [
            'Authorization' => 'Bearer ' . HUBSPOT_TOKEN,
            'Content-Type'  => 'application/json',
        ],
        'body' => wp_json_encode([
            'properties' => [
                'email'     => sanitize_email($data['your-email'] ?? ''),
                'firstname' => sanitize_text_field($data['your-name'] ?? ''),
            ],
        ]),
        'timeout' => 10,
    ]);
}

function cf7_send_to_mailchimp($contact_form) {
    if ((int) $contact_form->id() !== YOUR_FORM_ID) return;

    $submission  = WPCF7_Submission::get_instance();
    $data        = $submission->get_posted_data();
    $email       = sanitize_email($data['your-email'] ?? '');
    $server      = substr(MAILCHIMP_API_KEY, strrpos(MAILCHIMP_API_KEY, '-') + 1);
    $member_hash = md5(strtolower($email));

    wp_remote_request(
        "https://{$server}.api.mailchimp.com/3.0/lists/" . MAILCHIMP_LIST_ID . "/members/{$member_hash}",
        [
            'method'  => 'PUT',
            'headers' => [
                'Authorization' => 'Basic ' . base64_encode('anystring:' . MAILCHIMP_API_KEY),
                'Content-Type'  => 'application/json',
            ],
            'body' => wp_json_encode([
                'email_address' => $email,
                'status_if_new' => 'subscribed',
            ]),
            'timeout' => 10,
        ]
    );
}

function cf7_send_to_google_sheets($contact_form) {
    if ((int) $contact_form->id() !== YOUR_FORM_ID) return;

    $submission = WPCF7_Submission::get_instance();
    $data       = $submission->get_posted_data();

    wp_remote_post(
        "https://sheets.googleapis.com/v4/spreadsheets/" . SHEETS_ID . "/values/Sheet1!A:D:append?valueInputOption=USER_ENTERED",
        [
            'headers' => [
                'Authorization' => 'Bearer ' . SHEETS_SERVICE_ACCOUNT_TOKEN,
                'Content-Type'  => 'application/json',
            ],
            'body' => wp_json_encode([
                'values' => [[
                    sanitize_text_field($data['your-name'] ?? ''),
                    sanitize_email($data['your-email'] ?? ''),
                    sanitize_text_field($data['your-phone'] ?? ''),
                    sanitize_text_field($data['your-message'] ?? ''),
                ]],
            ]),
            'timeout' => 10,
        ]
    );
}
Enter fullscreen mode Exit fullscreen mode

Three API calls. Three different services. Three different authentication methods. All triggered by one form submission. No Zapier. No middleware.

The No-Code Version: Contact Form to API

If managing PHP across multiple functions is not your preference, Contact Form to API supports multiple API connections per form from the WordPress dashboard.

You add a connection for HubSpot, add another for Mailchimp, add another for Google Sheets all inside the same CF7 form settings tab. Each connection has its own endpoint URL, authentication headers, and field mapping. When the form submits, all connections fire simultaneously.

The free plan supports up to 5 API connections per form. Every connection logs the API response, so you can see whether HubSpot accepted the contact, whether Mailchimp added the subscriber, and whether Google Sheets appended the row all from one place in the WordPress dashboard.

Common Multi-API Routing Use Cases

CRM + Email Marketing:
Lead goes into HubSpot (or Salesforce) as a contact. Same submission adds them to Mailchimp (or Brevo) with a specific tag or list for the welcome sequence. Both happen simultaneously on submit.

CRM + Internal Logging:
Contact form submission creates a CRM lead and simultaneously appends a row to a Google Sheet that the ops team uses for daily lead review. No one has to export anything from the CRM.

CRM + Notification:
Lead enters the CRM and a Slack message fires to the sales channel immediately. The sales team sees new leads in Slack in real time without logging into the CRM.

Multiple CRM Routing:
Enterprise setup where leads go to both a marketing CRM (Mailchimp/ActiveCampaign) and a sales CRM (Salesforce/HubSpot) simultaneously, with different field mappings for each.

Performance Consideration: Parallel vs Sequential Calls

By default, PHP's wp_remote_post calls are sequential. The second call starts only after the first completes. For three API calls with 10-second timeouts each, the worst case is 30 seconds of execution time.

In practice, APIs respond in 200-500ms under normal conditions, so three sequential calls typically complete in under 2 seconds fast enough that the form submission feels instant to the user.

If you need true parallel execution (rare for most CF7 use cases), WordPress does not natively support async HTTP calls. The practical solution is to use WordPress's action scheduler or a background processing plugin to queue the API calls and execute them outside the request lifecycle.

Summary

Sending CF7 submissions to multiple APIs simultaneously requires either:

  1. Multiple wpcf7_before_send_mail hook registrations in PHP (one per destination)
  2. A plugin like Contact Form to API that manages multiple connections from a UI

Neither approach requires Zapier, Make, or any external automation platform. The form submits, WordPress fires the hooks, all API calls happen server-side, and each destination receives the data within the same request execution window.

Top comments (0)