Skip to content

Instantly share code, notes, and snippets.

@JarrydLong
Last active August 7, 2023 14:39
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 JarrydLong/43263034adb88b568e7f64f48a3da910 to your computer and use it in GitHub Desktop.
Save JarrydLong/43263034adb88b568e7f64f48a3da910 to your computer and use it in GitHub Desktop.
<?php //do not copy
/**
* This recipe removes the HTML content type and adds a plain text content type for all PMPro emails
*
* You can add this recipe to your site by creating a custom plugin
* or using the Code Snippets plugin available for free in the WordPress repository.
* Read this companion article for step-by-step directions on either method.
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_email_headers( $headers, $email ) {
$new_headers = array();
foreach( $headers as $key => $header ) {
//Only use the headers that don't reference the content type
if ( strpos( $header, "text/html" ) === false ) {
$new_headers[] = $header;
}
}
//Set to plain text
$new_headers[] = "Content-Type: text/plain";
return $new_headers;
}
add_filter( "pmpro_email_headers", "my_pmpro_email_headers", 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment