Tutorial: How to Disable “Some Plugins Were Automatically Updated” e-mails

Are you receiving this “Some plugins were automatically updated” e-mail a bit too often to your taste?

Why do I reveive those e-mails?

That’s because your WordPress was set to automatically update your themes and plugins. Since WordPress 5.1.1, there is also an option in the Plugins section that allows you to enable this directly for specific plugins.

How can I disable those e-mails?

You could install a plugin, but personally, I prefer to avoid having plugins sor such little tasks, and keep my WordPress light. In fact, you just need a bit of code in your WordPress. This code can be added directly in your functions.php, or more simply, by using a plugin such as Code Snippets, which allow you to add custom code (yes, it’s one plugin, but with it you can avoid installing a bunch of others).

Here is the code:

global $wp_version;

if ( version_compare( $wp_version, '5.5.1' ) >= 0) {
  // Only send emails when the plugin or theme failed to update.
  add_filter( 'auto_plugin_update_send_email', 'handle_auto_plugin_update_send_email', 10, 2 );
  add_filter( 'auto_theme_update_send_email', 'handle_auto_plugin_update_send_email', 10, 2 );
} 
else {
  // Disable the emails sent everytime there is a plugin or theme update.
  add_filter( 'auto_plugin_update_send_email', 'disable_auto_plugin_update_send_email', 10, 1 );
  add_filter( 'auto_theme_update_send_email', 'disable_auto_plugin_update_send_email', 10, 1 );
} 

function disable_auto_plugin_update_send_email() {
  return false;
}

function handle_auto_plugin_update_send_email( $enabled, $update_results = null ) {
  if ( is_array( $update_results ) ) {
    foreach ( $update_results as $update_result ) {
      if ( !$update_result->result ) {
        return $enabled;
      }
    }
  }
  return false;
}

This code will avoid emails to be sent, except if one plugin (or theme) couldn’t be updated successfuly.

Little Warning

Having your plugins and themes being updated successfuly might sound great, but this is also dangerous: if there is an issue with one of them, your website might go dow, and that might also happen because of some new compatibility issues. So, here is my advice:

Make sure your site has a daily backup. If not, avoid enabling Automatic Updates.