Skip to content

Instantly share code, notes, and snippets.

@strangerstudios
Created September 7, 2012 16:24
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save strangerstudios/3667545 to your computer and use it in GitHub Desktop.
Save strangerstudios/3667545 to your computer and use it in GitHub Desktop.
Disable All PMPro Emails
<?php
/*
Plugin Name: PMPro Disable All Emails
Plugin URI: http://www.paidmembershipspro.com/wp/pmpro-disable-all-emails/
Description: Disable All PMPro Emails
Version: .1
Author: Stranger Studios
Author URI: http://www.strangerstudios.com
Add this file to your /wp-content/plugins/ folder and then activate it from the Plugins page in your WP admin.
*/
/*
Disable all PMPro Emails
*/
function dae_pmpro_email_recipient($recipient, $email)
{
//if($email->template == "invoice") //use this to check for a certain template
$recipient = NULL;
return $recipient;
}
add_filter("pmpro_email_recipient", "dae_pmpro_email_recipient", 10, 2);
@pythoninthegrass
Copy link

Hi Stranger Studios,

This Gist sadly doesn't work with PMPro 1.8.1. I get this message:

Warning: PMPro Disable All Emails needs to be UPDATED to version 1.3.0 to function properly. __( 'If you have not received an update notification for this plugin you may re-download the plugin/extension from your SlickRemix 'My Account' page., 'fts-bar' ) .

To be quite honest, I'm not really a developer (yet) and don't really know what code to add to ignore the version number or spoof the 1.3.0 requirement.

While I know that there is a paid support route, financial restraints will necessitate the need to look for another plugin to handle paid memberships at this point in time.

Thank You,
Lance

EDIT
Turns out that by installing the PMPro Email Template plugin, there is an option to disable outgoing email: Memberships > Email Templates > Email Template: Membership Expired then check "Disable this email." Problem solved!

...That is assuming letting members know their membership expired isn't a priority compared to members getting up to eight emails a day to remind them they're no longer members.

@FranciscoHV
Copy link

Thanks for the information pythoninthegrass!!

Turns out that by installing the PMPro Email Template plugin, there is an option to disable outgoing email: Memberships > Email Templates > Email Template: Membership Expired then check "Disable this email." Problem solved!

@ideadude
Copy link

I just tested this as a plugin in 2020 and it still works for me. I'm not sure why the upgrade notification came up for the user above. Maybe it was an issue with our license server back then. Maybe there was a .org plugin with the same name.

In any case, the Email Templates Add On setting is one way to do this on a per email basis. You can also use our PMPro Toolkit Add On to block emails. There are other plugins that do this as well.

The tactic of blanking out the email recipient like this works well. So you can use a one liner like this:

add_filter("pmpro_email_recipient", "__return_false" );

Note this filters only PMPro emails. Similar tactics should work for all WP email using the core WP filters.

@Dromptar
Copy link

Dromptar commented Jun 1, 2023

Hello there ! Thank you for this great snippet. I have 2 questions "

  • I'm trying to block automatics mails to admins, not to users. How could we do that ?
  • Where can I find the name of a different template like here "invoice" if I want to disable other one ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment