Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save strangerstudios/4699285 to your computer and use it in GitHub Desktop.
Save strangerstudios/4699285 to your computer and use it in GitHub Desktop.
/*
Only change the from email/name on PMPro emails.
This code is useful if Paid Memberships Pro is updating the from name and email on non-PMPro emails and you don't want it to.
Add this code to your active theme's functions.php or a custom plugin.
*/
function my_pmpro_email_headers_init()
{
//first remove the default actions
remove_filter('wp_mail_from_name', 'pmpro_wp_mail_from_name');
remove_filter('wp_mail_from', 'pmpro_wp_mail_from');
//filters to update from name and email in PMProEmail class
add_filter('pmpro_email_sender_name', 'pmpro_wp_mail_from_name');
add_filter('pmpro_email_sender', 'pmpro_wp_mail_from');
}
add_action("init", "my_pmpro_email_headers_init");
//actually use those values when sending the email
function my_pmpro_email_headers($headers, $email)
{
$pmpro_from_name = pmpro_getOption("from_name");
$pmpro_from_email = pmpro_getOption("from_email");
if(!empty($pmpro_from_name) && !empty($pmpro_from_email))
$headers[]="From: " . $pmpro_from_name . " <" . $pmpro_from_email . ">";
return $headers;
}
add_filter('pmpro_email_headers', 'my_pmpro_email_headers', 10, 2);
@laurenhagan0306
Copy link

This recipe is included in the blog post on "Only change the from email and name on PMPro emails." at Paid Memberships Pro here: https://www.paidmembershipspro.com/only-change-the-from-email-and-name-on-pmpro-emails/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment