Created
October 12, 2020 06:52
-
-
Save gausam/ff547ced22b769200bd6efc074f067b0 to your computer and use it in GitHub Desktop.
Copy an additional email address when admin approval is required for a specific membership level.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* This recipe copies an additional email address when admin approval is | |
* required for a specific membership level. | |
* | |
* It is intended for use with the Approval Process for Membership Add On: | |
* https://www.paidmembershipspro.com/add-ons/approval-process-membership/ | |
* | |
* 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_filter($email) { | |
$membership_level_id = 1; // use target membership level | |
$email_to_copy = "[email protected]"; // use correct email address | |
if ( | |
$email->template === 'admin_notification_approval' && | |
$email->data['membership_id'] === $membership_level_id | |
) { | |
// Make sure we have a headers array | |
if ( empty( $email->headers ) ) { | |
$email->headers = array(); | |
} elseif ( ! is_array( $email->headers ) ) { | |
$email->headers = array( $email->headers ); | |
} | |
$email->headers[] = "Cc:" . $email_to_copy; | |
} | |
return $email; | |
} | |
add_filter( 'pmpro_email_filter', 'my_pmpro_email_filter' , 10, 1); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment