-
-
Save 2ndkauboy/25c50c0540c9635c5a63 to your computer and use it in GitHub Desktop.
Enables a debugger for the contact form 7 plugin that will add the error info to the AJAX response
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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
The status text for a spam report can also be "spam". Maybe an
if ($result['status'] == "spam")
would be useful as an addition.