Skip to content

Instantly share code, notes, and snippets.

@Shelob9
Last active August 29, 2015 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Shelob9/bb202bcec2170b64b406 to your computer and use it in GitHub Desktop.
Save Shelob9/bb202bcec2170b64b406 to your computer and use it in GitHub Desktop.
<?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