Forked from femiyb/disable_email_template_memberlevel.php
Last active
September 6, 2021 21:04
-
-
Save MaryOJob/82b812ee71cc400f6a91999e36997c5b to your computer and use it in GitHub Desktop.
Disable Recurring Payment Reminder Emails for Specific Levels - PMPro
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 | |
/** | |
* This recipe will disable the recurring payment email reminders for the specifc levels stated | |
* | |
* 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); | |
$disabled_levels = array(1,3); //update this to include ids of all levels you want to disable emails for | |
if(!empty($level) && !empty($level->id) && in_array( intval( $level->id ), $disabled_levels) && $email->template == "membership_recurring") | |
$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