# Email When Plugin or Theme Updates Are Available

> Checks once a day for plugin, theme and WordPress updates and emails the admin a list when there is something new to install, so outdated software does not linger.

- Type: PHP
- Runs: Run everywhere
- Category: [Email](https://wpide.com/library/category/email/)
- Tags: email, updates, maintenance
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/email-updates-available-alert/

## Code

```php
add_action( 'init', function () {
    if ( ! wp_next_scheduled( 'wpide_updates_alert' ) ) {
        wp_schedule_event( time() + HOUR_IN_SECONDS, 'daily', 'wpide_updates_alert' );
    }
} );

add_action( 'wpide_updates_alert', function () {
    $lines   = array();
    $plugins = get_site_transient( 'update_plugins' );
    $themes  = get_site_transient( 'update_themes' );
    $core    = get_site_transient( 'update_core' );

    if ( ! empty( $plugins->response ) ) {
        if ( ! function_exists( 'get_plugins' ) ) {
            require_once ABSPATH . 'wp-admin/includes/plugin.php';
        }
        $installed = get_plugins();
        foreach ( $plugins->response as $file => $data ) {
            $name    = isset( $installed[ $file ]['Name'] ) ? $installed[ $file ]['Name'] : $file;
            $lines[] = sprintf( 'Plugin: %s → %s', $name, $data->new_version );
        }
    }
    if ( ! empty( $themes->response ) ) {
        foreach ( $themes->response as $slug => $data ) {
            $lines[] = sprintf( 'Theme: %s → %s', $slug, $data['new_version'] );
        }
    }
    if ( ! empty( $core->updates[0] ) && 'upgrade' === $core->updates[0]->response ) {
        $lines[] = 'WordPress → ' . $core->updates[0]->current;
    }

    $hash = md5( implode( '|', $lines ) );
    if ( ! $lines || get_option( 'wpide_updates_alert_hash' ) === $hash ) {
        return;
    }
    update_option( 'wpide_updates_alert_hash', $hash, false );

    wp_mail( get_option( 'admin_email' ), sprintf( '[%s] %d update(s) available', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ), count( $lines ) ), "These updates are ready to install:\n\n" . implode( "\n", $lines ) . "\n\nUpdate now: " . admin_url( 'update-core.php' ) );
} );
```

## Notes

Only emails when the list of available updates changes, so you are not reminded daily about the same ones.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Email When Plugin or Theme Updates Are Available" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
