Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Enables a debugger for the contact form 7 plugin that will add the error info to the AJAX response
<?php
/**
* Plugin Name: Debug for Contact Form 7
* Description: Enables a debugger for the contact form 7 plugin that will add the error info to the AJAX response
* Version: 1.0.0
* Author: Bernhard Kau
* Author URI: https://kau-boys.de
* License: GPLv3
* License URI: http://www.gnu.org/licenses/gpl-3.0
*/
/**
* @param array $items The items for the JSON response
* @param array $result The result of the mail submission
*
* @global PHPMailer $phpmailer The global PHPMailer object
*
* @return array The items array
*/
function debug_for_contact_form_7_add_error_to_ajax_response( $items, $result ) {
if ( 'mail_failed' == $result['status'] ) {
global $phpmailer;
$items['errorInfo'] = $phpmailer->ErrorInfo;
}
return $items;
}
add_action( 'wpcf7_ajax_json_echo', 'debug_for_contact_form_7_add_error_to_ajax_response', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.