Skip to content

Instantly share code, notes, and snippets.

@ideadude
Last active March 26, 2024 06:44
Show Gist options
  • Save ideadude/3ab0197ba67084b671a4eec5983f9f01 to your computer and use it in GitHub Desktop.
Save ideadude/3ab0197ba67084b671a4eec5983f9f01 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.
<?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(
60 => 'membership_expiring_1',
30 => 'membership_expiring_2',
10 => 'membership_expiring_3',
);
return $settings;
}
add_filter( 'pmproeewe_email_frequency_and_templates', 'my_custom_pmproeewe_email_frequency_and_templates', 10, 1 );
// Add the templates.
function my_add_extra_expiration_warning_templates( $templates ) {
$templates['membership_expiring_1'] = array(
'subject' => "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' => "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' => "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