Skip to content

Instantly share code, notes, and snippets.

@andrewlimaza
Created February 14, 2020 08:55
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 andrewlimaza/fc372ea171888e5da21f9a4c37897c05 to your computer and use it in GitHub Desktop.
Save andrewlimaza/fc372ea171888e5da21f9a4c37897c05 to your computer and use it in GitHub Desktop.
Change Admin "To" address for admin emails [Paid Memberships Pro]
<?php
/**
* Change the "To:" header for admin emails for Paid Memberships Pro.
* Follow this guide to add custom code to your site - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_change_admin_to_email( $headers, $email ){
if( strpos( $email->template, "_admin" ) !== false ) {
//add different email for admin emails.
$headers[] = "To: " . "otheremail@domain.com";
}
return $headers;
}
add_filter( "pmpro_email_headers", "my_pmpro_change_admin_to_email", 10, 2 );
@jescott2
Copy link

When I saw this, I expected the script to change the To email address for the site administrator. The result was the new email was added to teh original recipient email so a membership change is sent to two recipients. Is this your expected result? Is there another place I need to edit?

@andrewlimaza
Copy link
Author

Hi @jescott2, here is an updated code that should work for you - https://gist.github.com/andrewlimaza/78a4e1fb266b633aa5b138047576bfcc

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