apply_filters( ‘auto_plugin_theme_update_email’, array $email, string $type, array $successful_updates, array $failed_updates )

Filters the email sent following an automatic background update for plugins and themes.

Parameters

$emailarray
Array of email arguments that will be passed to wp_mail() .
  • to string
    The email recipient. An array of emails can be returned, as handled by wp_mail() .
  • subject string
    The email’s subject.
  • body string
    The email message body.
  • headers string
    Any email headers, defaults to no headers.
$typestring
The type of email being sent. Can be one of 'success', 'fail', 'mixed'.
$successful_updatesarray
A list of updates that succeeded.
$failed_updatesarray
A list of updates that failed.

Source

$email = apply_filters( 'auto_plugin_theme_update_email', $email, $type, $successful_updates, $failed_updates );

Changelog

VersionDescription
5.5.0Introduced.

User Contributed Notes

  1. Skip to note 2 content

    The apply_filters( 'auto_plugin_theme_update_email', $email, $type, $successful_updates, $failed_updates ) filter is used in WordPress to modify the email content that gets sent after an automatic update of plugins or themes.

    Add the following code to your theme’s functions.php file or in a custom plugin.

    add_filter( 'auto_plugin_theme_update_email', 'wpdocs_auto_update_email', 10, 4 );
    
    function wpdocs_auto_update_email( $email, $type, $successful_updates, $failed_updates ) {
        // Customize the subject line
        $email['subject'] = 'Custom Subject: Updates on Your Site';
    
        // Customize the body content
        $email['body'] = 'Hello! Here are the updates that were applied:';
    
        if ( ! empty( $successful_updates ) ) {
            $email['body'] .= "\n\n" . __( 'Successful updates:' );
    
            foreach ( $successful_updates as $item ) {
                $email['body'] .= "\n" . '- ' . $item->name;
            }
        }
    
        if ( ! empty( $failed_updates ) ) {
            $email['body'] .= "\n\n" . __( 'Failed updates:' );
    
            foreach ( $failed_updates as $item ) {
                $email['body'] .= "\n" . '- ' . $item->name;
            }
        }
    
        return $email;
    }

You must log in before being able to contribute a note or feedback.