DEV Community

Cover image for CF7 Webhook Throwing a 500 Error? Checkboxes and Acceptance Fields Are Probably the Cause
Rahul Sharma
Rahul Sharma

Posted on

CF7 Webhook Throwing a 500 Error? Checkboxes and Acceptance Fields Are Probably the Cause

You set up a webhook in CF7 to send form data to an external service. You test it with a simple email field and it works perfectly. Then you add a checkbox, an acceptance field, or a multi-select dropdown to your form and suddenly every submission throws a 500 error.

The form stops working entirely. No data reaches your webhook. Your visitors see a broken form.

This is a real bug that was reported on the WordPress support forums and confirmed across WordPress 6.9, PHP 8.2, and CF7 6.1.4. Here is exactly what is happening and how to fix it.

What Is Actually Going Wrong

When a user submits a CF7 form, the webhook feature takes the field values and replaces the placeholders in your webhook body template with the actual submitted values.

For a simple text or email field, the value is a plain string. The replacement works fine.

But checkbox fields, acceptance fields, and multi-select dropdowns return arrays in PHP, not strings. When the webhook code tries to do a string replacement with an array value, PHP throws a fatal error:

PHP Fatal error: Uncaught TypeError: str_replace(): Argument #2 ($replace)
must be of type string when argument #1 ($search) is a string
in webhook.php:464
Enter fullscreen mode Exit fullscreen mode

The CF7 Apps plugin assumed every field value would be a string. Acceptance checkboxes, regular checkboxes, and multi-select dropdowns break that assumption because they return multiple selected values as an array.

The result: a 500 server error on every submission that includes those field types.

Which Field Types Trigger This Error

Three CF7 field types cause this problem:

Acceptance fields — the GDPR consent checkbox that CF7 provides:

[acceptance accept-terms] I agree to the terms[/acceptance]
Enter fullscreen mode Exit fullscreen mode

Checkbox fields — any field using [checkbox]:

[checkbox services "Web Design" "SEO" "Hosting"]
Enter fullscreen mode Exit fullscreen mode

Dropdowns with the multiple attribute — allowing users to select more than one option:

[select* services multiple "Option 1" "Option 2" "Option 3"]
Enter fullscreen mode Exit fullscreen mode

All three return arrays from CF7's submission handler. Any webhook plugin that does not handle arrays will throw the same fatal error.

The Quick Fix If You Must Keep Using CF7 Apps Webhook

The CF7 Apps team released a beta fix for this bug. If you are already committed to using their webhook feature, download the beta from their support thread and install it manually.

However, be aware that even after the fix, single-select dropdowns send their values as a JSON array with one item rather than a plain string. So a user selecting "Option 2" from a dropdown arrives at your webhook as ["Option 2"] instead of "Option 2". Depending on what your receiving API expects, this may cause further problems.

The Better Fix: Use a Plugin That Handles Arrays Properly From the Start

Patching around bugs in webhook plugins is a maintenance burden. Every time CF7 updates or the webhook plugin updates, you risk the same class of problem coming back.

Contact Form to API was built specifically to handle CF7 form data and send it to external APIs correctly. It handles checkbox arrays, acceptance fields, and multi-select dropdowns without throwing 500 errors because it processes CF7's submission data properly before building the outbound request.

You get a clean configuration interface where you map CF7 fields to your API's expected format, set your endpoint URL, configure authentication headers, and test the connection all from the WordPress dashboard. No fatal PHP errors. No broken forms.

Why This Keeps Happening With CF7 Webhooks

CF7's field types fall into two categories: fields that return a single string value (text, email, phone, textarea) and fields that return arrays (checkboxes, acceptance, multi-select). Most webhook plugins are built and tested only with the simple string fields. Array fields get added to forms later and the webhook silently breaks.

The pattern repeats across different plugins because the underlying issue is the same: not checking the type of a field value before doing string operations on it.

If your form collects consent, services selected, or any kind of multi-option choice, you need a webhook or API integration tool that explicitly handles arrays. Contact Form to API converts array field values (comma-separated or serialized) into a format your API can consume, so your checkbox selections arrive at your CRM cleanly rather than crashing the whole submission.

What to Check If You Are Seeing a 500 Error

If your CF7 form is throwing a 500 error on submission and you have a webhook configured, check these things in order:

First, look at your server's PHP error log. The error will include a stack trace pointing to the exact file and line. If you see str_replace() with a TypeError about array arguments, this is the same bug described here.

Second, check whether your form contains any checkbox, acceptance, or multi-select dropdown fields. Remove them temporarily and test the form. If the 500 error disappears, those fields are the trigger.

Third, decide whether to patch the existing webhook plugin or switch to a tool that handles CF7 field types correctly. If you are managing more than one form or more than one integration, switching to Contact Form to API pays off quickly because you manage everything from one reliable dashboard rather than hunting down bugs across multiple plugins.

Top comments (0)