Skip to content

Instantly share code, notes, and snippets.

@ipokkel
Created September 7, 2023 19:42
Show Gist options
  • Save ipokkel/1ea35c55439f07ccc34265ff117a239d to your computer and use it in GitHub Desktop.
Save ipokkel/1ea35c55439f07ccc34265ff117a239d to your computer and use it in GitHub Desktop.
<?php
/**
* Do not sent recurring payment reminder email if last order gateway is check.
*
* This may be useful to stop sending reminder emails to members already receiving
* pay by check email reminders.
*
* 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_pmprorm_dont_send_reminder_to_pbc( $send_mail, $user, $lastorder ) {
// Let's only do this if Pay By Check is active.
if ( ! function_exists( 'pmpropbc_reminder_emails' ) ) {
return $send_mail;
}
// if lastorder gateway is check, return false.
if ( 'check' === $lastorder->gateway ) {
return false;
}
return $send_mail;
}
add_filter( 'pmprorm_send_reminder_to_user', 'my_pmprorm_dont_send_reminder_to_pbc', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment