Created
February 1, 2021 11:39
-
-
Save MaryOJob/9181c71f911dae10ab75767fe592c9ab to your computer and use it in GitHub Desktop.
Disable member email for a specific email template for a specific 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 // 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