Last active
March 7, 2016 19:59
-
-
Save shanebp/4270480b6afcb179ed77 to your computer and use it in GitHub Desktop.
Plugin: send debug emails to site admin re BP_Mail
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: 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