Last active
January 21, 2022 09:57
-
-
Save MaryOJob/81c13a1f12d62208233542d3fcd3352f to your computer and use it in GitHub Desktop.
Disable Recurring Payment Reminder Emails for Specific Level(s) - PMPro
This file contains hidden or 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 disable_recurring_payment_reminder_email_per_level( $email ) { | |
/* | |
Set level IDs to disable here | |
Replace "1, 2" with the ids of your membership level you want to disable | |
e.g. $disabled_levels = array( 1, 2 ); // cancels this email for level 1 and level 2 | |
$disabled_levels = array( 1 ); // cancels this email for level 1 only. | |
*/ | |
$disabled_levels = array( 1, 2 ); | |
if ( 'membership_recurring' === $email->template ) { | |
if ( in_array( $email->data['membership_id'], $disabled_levels ) ) { | |
$email = false; | |
} | |
} | |
return $email; | |
} | |
add_filter( 'pmpro_email_filter', 'disable_recurring_payment_reminder_email_per_level', 10, 1 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment