WordPress sends an email after every automatic update, for core, plugins and themes. With auto-updates turned on across several sites, those emails turn into noise, and the ones that matter, failed updates, get lost among them.
This snippet disables the routine success emails and keeps the ones that need action: a failed or critical core update, and any plugin or theme update run where something did not install.
The snippet
<?php
add_filter( 'auto_core_update_send_email', 'dpc_core_update_email_on_failure_only', 10, 2 );
/**
* Skip the "your site has updated" email, keep failure and critical emails.
*/
function dpc_core_update_email_on_failure_only( $send, $type ) {
if ( 'success' === $type ) {
return false;
}
return $send;
}
add_filter( 'auto_plugin_update_send_email', 'dpc_extension_update_email_on_failure_only', 10, 2 );
add_filter( 'auto_theme_update_send_email', 'dpc_extension_update_email_on_failure_only', 10, 2 );
/**
* Send the plugin or theme update email only when at least one update failed.
*/
function dpc_extension_update_email_on_failure_only( $enabled, $update_results ) {
foreach ( (array) $update_results as $result ) {
if ( isset( $result->result ) && true !== $result->result ) {
return $enabled;
}
}
return false;
}
Add it with Scripts Organizer
Scripts Organizer ships this snippet in its One-Click Import library. To add it by hand:
- In wp-admin go to Scripts Organizer → Code Blocks → Add New and give the block a title.
- Script location: PHP.
- Trigger location: Everywhere. Automatic updates run from WP-Cron, which is neither a wp-admin screen nor a normal front-end page view, so Admin only and Conditions would miss it.
- Action hook: leave it empty. The code only registers filters and actions, so it can run while plugins load.
- Paste the snippet into the PHP editor, enable the block and publish it.
The same code also works unchanged in a small plugin or an mu-plugin file in wp-content/mu-plugins/.
How it works
auto_core_update_send_emailreceives the email type:success,failorcritical. The snippet returnsfalseonly forsuccess. Emails about a manual update do not go through this filter at all.auto_plugin_update_send_emailandauto_theme_update_send_emailreceive the results of one update run. Each result has aresultproperty that istruewhen that update worked. If every result istrue, the email is dropped. If any update failed, the normal email goes out and lists the successes and failures together.- Older copies of this snippet returned
falseon all three filters, which also silenced failure and critical emails, the ones you want to see.
Customise it
To silence plugin and theme emails completely and keep only core failure emails, replace the two plugin and theme add_filter() lines with these:
add_filter( 'auto_plugin_update_send_email', '__return_false' );
add_filter( 'auto_theme_update_send_email', '__return_false' );
To send update emails to another address than the site admin, filter auto_core_update_email and auto_plugin_theme_update_email. Both receive the email as an array with a to key.
Gotchas
- On development and release candidate versions WordPress also sends a debug email after core updates. That one is controlled by
automatic_updates_send_debug_email, not by these filters. - If you get no email even when an update fails, check that the site can send mail at all; this snippet does not change delivery.
- To hear about security releases before they install, see WordPress Security Updates Email Alert Without a Plugin. To stop updates instead of emails, see Disable WordPress Core, Plugins and Themes updates and Admin Notices.
In the Scripts Organizer library Import it with one click from Scripts Organizer.