• Resolved clamburger

    (@clamburger)


    Using CF7’s built-in acceptance field causes a fatal error to occur when submitting a CF7 form configured to use a webhook. This issue also affects checkboxes, and drop-downs with the multiple option.

    Form example:

    <label>Email [email* email]</label>
    [acceptance Accept] I consent to being contacted[/acceptance]
    [submit "Submit"]

    Request Body:

    {"email":"[email]"}

    Stacktrace:

    NOTICE: PHP message: PHP Fatal error:  Uncaught TypeError: str_replace(): Argument #2 ($replace) must be of type string when argument #1 ($search) is a string in /app/public_html/wp-content/plugins/contact-form-7-honeypot/includes/apps/webhook/webhook.php:464
    Stack trace:
    #0 /app/public_html/wp-content/plugins/contact-form-7-honeypot/includes/apps/webhook/webhook.php(464): str_replace('[Accept]', Array, '{"email":"test@...')
    #1 /app/public_html/wp-content/plugins/contact-form-7-honeypot/includes/apps/webhook/webhook.php(432): CF7Apps_Webhook->prepare_webhook_data(5, Array, Array)
    #2 /app/public_html/wp-includes/class-wp-hook.php(341): CF7Apps_Webhook->handle_webhook_submission(Object(WPCF7_ContactForm))
    #3 /app/public_html/wp-includes/class-wp-hook.php(365): WP_Hook->apply_filters('', Array)
    #4 /app/public_html/wp-includes/plugin.php(522): WP_Hook->do_action(Array)
    #5 /app/public_html/wp-content/plugins/contact-form-7/includes/submission.php(127): do_action('wpcf7_mail_sent', Object(WPCF7_ContactForm))
    [truncated]

    The code seems to assume that all form values will be strings, when some of them are actually arrays.

    Tested with:

    • WordPress 6.9
    • PHP 8.2
    • Contact Form 7 6.1.4
    • CF7 Apps 3.4.0
    • This topic was modified 4 months, 2 weeks ago by clamburger. Reason: typos
    • This topic was modified 4 months, 2 weeks ago by clamburger. Reason: add tesst versions
Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support fahadwaheed

    (@fahadwaheed)

    Hi @clamburger

    I hope you’re doing well.

    Thank you for reaching out to the CF7 Apps Support Team. I’ll be replicating the issue on my end and discussing it with our Technical Team. I’ll share an update with you as soon as possible.

    We appreciate your patience in the meantime.

    Plugin Support fahadwaheed

    (@fahadwaheed)

    Hi @clamburger

    I hope you’re doing well.

    Thank you for your patience. We’re pleased to inform you that the issue has been resolved in the updated beta version of the plugin. You can download it using the link below:

    Download Beta Plugin

    After installing, please check the functionality and share your feedback with us. Once we receive your feedback, we’ll include this fix in the upcoming release.

    Looking forward to your response.

    Plugin Support fahadwaheed

    (@fahadwaheed)

    Hi @clamburger,

    I hope you’re doing well.

    I’m following up regarding the beta version of the plugin we shared earlier. Have you had a chance to test it? We’d appreciate it if you could share your feedback after testing so we can include the fix in the upcoming release.

    Looking forward to your response.

    Plugin Support fahadwaheed

    (@fahadwaheed)

    Hi @clamburger

    I hope you are doing well,

    We are marking this thread as resolved due to inactivity. If you encounter any further issues, please feel free to open a new thread.

    Have a great day!

    neumicha

    (@neumicha)

    Dear @fahadwaheed ,
    I tested your patch. It solves this bug!

    Only thing i noticed: I am using a drop-down field in my form so only one value can be chosen. The value however is send as a JSON list to the webhook. E.g.:

    [select my-dropdown "1" "2" "3"]

    Will result in the following payload at the called webhook:

    "body": {
    "form_id": "1651",
    "fields": {
    ... other fields ...
    "my-dropdown": [
    "2"
    ]
    }
    }

    If that’s the exepected behavior for dropdown values (that are always single-select?), that’s fine for me. Please add it to your regular release 🙂

    Thanks. Best regards.

Viewing 5 replies - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.