Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
/**
Plugin Name: Caldera Form Mail Debug Helper
Version: 0.1.0
*/
/**
* Write data to log
*/
function cf_mail_debug_write_log ( $log ) {
if ( is_array( $log ) || is_object( $log ) ) {
error_log( print_r( $log, true ) );
} else {
error_log( $log );
}
}
/**
* Log data sent to mailer.
*/
add_action( 'caldera_forms_do_mailer', 'cf_mailer_debug_capture_details', 99, 3 );
function cf_mailer_debug_capture_details( $mail, $data, $form ) {
global $transdata;
$entry_id = $transdata['entry_id'];
$log = array( 'entry_id' => $entry_id, 'save_point' => 'pre_send', 'recipients' => $mail[ 'recipients'] );
cf_mail_debug_write_log( $log );
}
/**
* Log data from mailer errors.
*/
add_action( 'caldera_forms_mailer_failed', 'cf_mailer_debug_capture_failer_details', 10, 3 );
function cf_mailer_debug_capture_failer_details($mail, $data, $form) {
global $transdata;
$entry_id = $transdata['entry_id'];
$log = array( 'entry_id' => $entry_id, 'save_point' => 'pre_send', 'recipients' => $mail[ 'recipients'] );
cf_mail_debug_write_log( $log );
}
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.