The auto_theme_update_send_email WordPress PHP filter allows you to control whether an email is sent after an automatic background theme update.
Usage
add_filter('auto_theme_update_send_email', 'your_custom_function', 10, 2); function your_custom_function($enabled, $update_results) { // your custom code here return $enabled; }
Parameters
$enabled
(bool): True if theme update notifications are enabled, false otherwise.$update_results
(array): The results of theme update tasks.
More information
See WordPress Developer Resources: auto_theme_update_send_email
Examples
Disable theme update email notifications
Prevent theme update email notifications from being sent.
add_filter('auto_theme_update_send_email', '__return_false', 10, 2);
Enable theme update email notifications
Ensure theme update email notifications are always sent.
add_filter('auto_theme_update_send_email', '__return_true', 10, 2);
Send theme update email notifications only for specific themes
Send email notifications only when specific themes are updated.
add_filter('auto_theme_update_send_email', 'send_emails_for_specific_themes', 10, 2); function send_emails_for_specific_themes($enabled, $update_results) { // List of themes for which to send email notifications $allowed_themes = array('twentytwenty', 'twentytwentyone'); foreach ($update_results as $result) { if (in_array($result['theme'], $allowed_themes)) { return true; } } return false; }
Send theme update email notifications only if an update fails
Send email notifications only when a theme update fails.
add_filter('auto_theme_update_send_email', 'send_emails_on_update_failure', 10, 2); function send_emails_on_update_failure($enabled, $update_results) { foreach ($update_results as $result) { if ($result['result'] === false) { return true; } } return false; }
Modify theme update email content
Change the subject and content of theme update email notifications.
add_filter('auto_theme_update_send_email', 'modify_theme_update_email', 10, 2); function modify_theme_update_email($enabled, $update_results) { // Modify email subject add_filter('auto_theme_update_email_subject', function($subject) { return 'New Theme Update Subject'; }); // Modify email content add_filter('auto_theme_update_email_content', function($content) { return 'New Theme Update Content'; }); return $enabled; }