Skip to content

Instantly share code, notes, and snippets.

@Pebblo
Last active August 14, 2019 11:35
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 Pebblo/bfd6aa3b88a2459668504f75a57bc324 to your computer and use it in GitHub Desktop.
Save Pebblo/bfd6aa3b88a2459668504f75a57bc324 to your computer and use it in GitHub Desktop.
Example of how you can add the returns from wp_mail_error logs to the EE messages error output
<?php // Please do not include the opening PHP tag if you already have one.
add_filter('FHEE__EE_Email_messenger___headers', 'tw_ee_hacky_wp_mail_error_for_messages__EE_Email_messenger___headers', 10, 3);
function tw_ee_hacky_wp_mail_error_for_messages__EE_Email_messenger___headers( $headers, $incoming_message_type, $messenger ){
add_action('wp_mail_failed', 'tw_log_wp_mail_errors', 10, 1);
return $headers;
}
function tw_log_wp_mail_errors($wp_error)
{
$wp_mail_errors = implode(",<br />", $wp_error->get_error_messages());
EE_Error::add_error(
sprintf(
esc_html__(
'Errors received from wp_mail_failed hook:%1$s%2$s',
'event_espresso'
),
'<br />',
$wp_mail_errors
),
__FILE__,
__FUNCTION__,
__LINE__
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment