Skip to content

Instantly share code, notes, and snippets.

@shanebp
Last active March 7, 2016 19:59
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 shanebp/4270480b6afcb179ed77 to your computer and use it in GitHub Desktop.
Save shanebp/4270480b6afcb179ed77 to your computer and use it in GitHub Desktop.
Plugin: send debug emails to site admin re BP_Mail
<?php
/* plugin name: BP Email Debug */
add_action( 'bp_send_email_failure', 'pg_bp25_email_debug_failure', 10, 2 );
add_action( 'bp_send_email_success', 'pg_bp25_email_debug_success', 10, 2 );
function pg_bp25_email_debug_failure( $status, $email ) {
$email_admin = bp_get_option( 'admin_email' );
if ( is_wp_error( $status ) ) {
$message = $status->get_error_message() . PHP_EOL . PHP_EOL . print_r( $email, true );
} else {
$message = 'Failure but not WP_Error.';
}
wp_mail( $email_admin, 'BuddyPress 2.5 email -- failure debug', $message );
}
function pg_bp25_email_debug_success( $status, $email ) {
$email_admin = bp_get_option( 'admin_email' );
if ( $status ) {
$message = 'Email delivered - true';
} else {
$message = 'Email success but not boolean true.';
}
wp_mail( $email_admin, 'BuddyPress 2.5 email -- success debug', $message );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment