Skip to content

Instantly share code, notes, and snippets.

@andrewlimaza
Created September 10, 2019 13:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save andrewlimaza/e83b1f032d590929ba4697316f457e89 to your computer and use it in GitHub Desktop.
Save andrewlimaza/e83b1f032d590929ba4697316f457e89 to your computer and use it in GitHub Desktop.
BCC email addresses based on membership level.
<?php
/**
* Tweaked from BCC Admin on Member Emails - https://www.paidmembershipspro.com/bcc-additional-email-addresses-on-member-or-admin-notifications/
* Add this code to your PMPro Customizations Plugin.
* Adjust the membership ID to match that of your levels.
*/
function my_pmpro_email_headers( $headers, $email ) {
// Default BCC address to default email address.
$admin_email = get_bloginfo("admin_email");
if ( intval( $email->data['membership_id'] ) == 5 ) {
$admin_email = 'someemail@email.com';
}
//bcc emails not already going to admin_email
if ( $email->email != get_bloginfo( "admin_email" ) ) {
$headers[] = "Bcc:" . $admin_email;
}
return $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