Forked from ideadude/my_add_extra_expiration_warning_templates.php
Last active
July 10, 2025 13:25
-
-
Save kimwhite/ca1b7c5b4ab6537a7238ef845c9701fc to your computer and use it in GitHub Desktop.
Send extra expiration warning emails with individual templates when using PMPro and the Extra Expiration Warning Emails add on.
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 | |
| /** | |
| * Send extra expiration warning emails with individual templates. | |
| * Make sure the Extra Expiration Warning Emails Add On is also active. | |
| * https://www.paidmembershipspro.com/add-ons/extra-expiration-warning-emails-add-on/ | |
| * | |
| * Then add this code into a custom plugin or code snippet. | |
| * https://www.paidmembershipspro.com/how-to-add-code-to-wordpress/ | |
| */ | |
| // Tell the expiration warnings add on to use our templates. | |
| function my_custom_pmproeewe_email_frequency_and_templates( $settings ) { | |
| $settings = array( | |
| 10 => 'membership_expiring_1', | |
| 20 => 'membership_expiring_2', | |
| 60 => 'membership_expiring_3', | |
| ); | |
| return $settings; | |
| } | |
| add_filter( 'pmproeewe_email_frequency_and_templates', 'my_custom_pmproeewe_email_frequency_and_templates', 10, 1 ); | |
| // Remove the hard-coded email subject so that the custom subject above is used. | |
| function my_remove_pmproewee_email_subject( $translated_text, $text, $domain ) { | |
| if ( $domain === 'pmpro-extra-expiration-warning-emails' && $text === 'Your membership at %s will end soon' ) { | |
| return ''; | |
| } | |
| return $translated_text; | |
| } | |
| add_filter( 'gettext', 'my_remove_pmproewee_email_subject', 10, 3 ); | |
| // Add the templates. | |
| function my_add_extra_expiration_warning_templates( $templates ) { | |
| $templates['membership_expiring_1'] = array( | |
| 'subject' => "One Your membership at !!sitename!! will end soon.", | |
| 'description' => "Membership Expiring 1", | |
| 'body' => '<p>Replace This</p>', | |
| 'help_text' => "The first email sent members when their expiration date is approaching." | |
| ); | |
| $templates['membership_expiring_2'] = array( | |
| 'subject' => "Two Your membership at !!sitename!! will end soon.", | |
| 'description' => "Membership Expiring 2", | |
| 'body' => '<p>Replace This</p>', | |
| 'help_text' => "The second email sent members when their expiration date is approaching." | |
| ); | |
| $templates['membership_expiring_3'] = array( | |
| 'subject' => "Three Your membership at !!sitename!! will end soon.", | |
| 'description' => "Membership Expiring 3", | |
| 'body' => '<p>Replace This</p>', | |
| 'help_text' => "The third email sent members when their expiration date is approaching." | |
| ); | |
| return $templates; | |
| } | |
| add_filter( 'pmproet_templates', 'my_add_extra_expiration_warning_templates' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment