Contact Form 7 Breaks After Clicking Submit

Recently we discovered that our Contact Form 7 page appeared to be break after the submit button was pressed. A user could fill out the form and submit it but the page would get stuck on the spinning loading icon. A quick check into the underlying code revealed the plugin Lead info with country for Contact Form 7 version 2.2 had the following error:

Notice: Use of undefined constant body - assumed 'body' in /wp-content/plugins/contact-form-7-lead-info-with-country/wpshore_cf7_lead_tracking.php on line 61

There are a couple of quick fixes for this error. The first is to open your wp-config.php file and change line that says define(‘WP_DEBUG’, true); to define( ‘WP_DEBUG’, false );. But this only prevents the error from showing and doesn’t actually fix it. The second solution to get the form working would be to deactivate the offending plugin. But this results in removing useful functionality; thus deactivating a useful plugin doesn’t really fix the problem. Use FTP to open the file named in the error description and go to line 61.

/wp-content/plugins/contact-form-7-lead-info-with-country/wpshore_cf7_lead_tracking.php

The following line of code is the culprit.

if( strpos( $array[body], '<!doctype html>' ) !== false ) { // Check if email sent is HTML or plain text

To solve the error simply change the above line of code to this. (Notice the change from [body] to [‘body’].)

if( strpos( $array['body'], '<!doctype html>' ) !== false ) { // Check if email sent is HTML or plain text

Next, save the changes and the error should be gone! If the issue persists then another error is probably hiding in your website. Use our contact page if you wish to hire us to track down your website’s problem!