Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dparker1005/ab755e9a788503f117fa28bafae23a43 to your computer and use it in GitHub Desktop.
Save dparker1005/ab755e9a788503f117fa28bafae23a43 to your computer and use it in GitHub Desktop.
Prevents a cancellation email from being set if the user was assigned a new membership level during the cancellation process.
<?php
// Copy from below here
/*
* Prevents a cancellation email from being set if the user
* was assigned a new membership level during the cancellation
* process.
*/
function my_pmpro_disable_incorrect_cancellation_emails($recipient, $email)
{
if ( strpos($email->template, "cancel") !== false ) {
$user = get_user_by( 'login', $email->data['user_login'] );
if ( pmpro_hasMembershipLevel( null, $user->ID ) ) {
$recipient = NULL;
}
}
return $recipient;
}
add_filter("pmpro_email_recipient", "my_pmpro_disable_incorrect_cancellation_emails", 10, 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment