Skip to content

Instantly share code, notes, and snippets.

@femiyb
Last active September 6, 2021 20:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save femiyb/55205a1bc19b8e16b0cbb236a1c55895 to your computer and use it in GitHub Desktop.
Save femiyb/55205a1bc19b8e16b0cbb236a1c55895 to your computer and use it in GitHub Desktop.
<?php
function my_pmpro_disable_member_emails($recipient, $email)
{
$user = get_user_by('login', $email->data['user_login']);
$level = pmpro_getMembershipLevelForUser($user->ID);
$disabled_levels = array(1,2,3); //update this to include ids of all levels you want to disable emails for
if(!empty($level) && !empty($level->id) && in_array( intval( $level->id ), $disabled_levels) && $email->template == "membership_recurring")
$recipient = NULL;
return $recipient;
}
add_filter("pmpro_email_recipient", "my_pmpro_disable_member_emails", 10, 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment