The auto_core_update_send_email WordPress PHP filter allows you to control whether an email should be sent following an automatic background core update.
Usage
add_filter('auto_core_update_send_email', 'your_custom_function', 10, 4); function your_custom_function($send, $type, $core_update, $result) { // your custom code here return $send; }
Parameters
$send
(bool) – Whether to send the email. Default is true.$type
(string) – The type of email to send. Can be one of ‘success’, ‘fail’, ‘critical’.$core_update
(object) – The update offer that was attempted.$result
(mixed) – The result for the core update. Can be WP_Error.
More information
See WordPress Developer Resources: auto_core_update_send_email
Examples
Disable all core update emails
Disable all automatic core update emails regardless of their type.
add_filter('auto_core_update_send_email', '__return_false');
Send only critical update emails
Send automatic core update emails only for critical updates.
add_filter('auto_core_update_send_email', 'send_only_critical_emails', 10, 2); function send_only_critical_emails($send, $type) { return $type === 'critical'; }
Disable update emails for specific versions
Disable automatic core update emails for specific WordPress versions.
add_filter('auto_core_update_send_email', 'disable_specific_version_emails', 10, 3); function disable_specific_version_emails($send, $type, $core_update) { if ($core_update->current === '5.9.2') { return false; } return $send; }
Log update results instead of sending emails
Log automatic core update results instead of sending emails.
add_filter('auto_core_update_send_email', 'log_update_results', 10, 4); function log_update_results($send, $type, $core_update, $result) { error_log("Core update: $type, Version: {$core_update->current}, Result: " . json_encode($result)); return false; }
Change email behavior based on update result
Send email only when update failed or had a critical error.
add_filter('auto_core_update_send_email', 'send_on_fail_or_critical', 10, 4); function send_on_fail_or_critical($send, $type, $core_update, $result) { if (is_wp_error($result) || $type === 'critical') { return true; } return false; }