Skip to content

Instantly share code, notes, and snippets.

@imath
Last active May 13, 2020 17:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save imath/4faef242ae104c65ddb9ec711ea37189 to your computer and use it in GitHub Desktop.
Save imath/4faef242ae104c65ddb9ec711ea37189 to your computer and use it in GitHub Desktop.
Forces the BP email content to be HTML
<?php
/**
* @see https://buddypress.trac.wordpress.org/ticket/8104
* @see https://buddypress.trac.wordpress.org/ticket/8108
* @see https://buddypress.org/support/topic/buddypress-email-notification-ignoring-smtp-server-settings/
*/
function shawfactor_use_html_wp_mail() {
return 'text/html';
}
/**
* If you're using a plugin to send emails using wp_mail, it may
* already force HTML.
*/
add_filter( 'wp_mail_content_type', 'shawfactor_use_html_wp_mail' );
function shawfactor_get_bp_email_content_plaintext( $content = '', $property = 'content_plaintext', $transform = 'replace-tokens', BP_Email $bp_email ) {
// Make sure we're about to send an email.
if ( ! did_action( 'bp_send_email' ) ) {
return $content;
}
return $bp_email->get_template( 'add-content' );
}
add_filter( 'bp_email_get_content_plaintext', 'shawfactor_get_bp_email_content_plaintext', 10, 4 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment