Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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