Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save MaryOJob/9181c71f911dae10ab75767fe592c9ab to your computer and use it in GitHub Desktop.
Save MaryOJob/9181c71f911dae10ab75767fe592c9ab to your computer and use it in GitHub Desktop.
Disable member email for a specific email template for a specific level
<?php // Do Not Copy This Line
/**
* The function below will disable the membership expiring email (for a specific membereship level)
* sent to the Member/User by Paid Memberships Pro.
* The admin emails will still be sent as intended.
* 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_disable_member_emails($recipient, $email) {
$user = get_user_by('login', $email->data['user_login']);
$level = pmpro_getMembershipLevelForUser($user->ID);
if(!empty($level) && !empty($level->id) && $level->id == 1 && $email->template == "membership_expiring") // disable for level one only
$recipient = NULL;
return $recipient;
}
add_filter("pmpro_email_recipient", "my_pmpro_disable_member_emails", 10, 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment