# Weekly Security Summary Email

> Emails the administrator a short security summary every week: pending WordPress, plugin and theme updates, administrator accounts, new users of the week, inactive plugins and whether debug mode is on.

- Type: PHP
- Runs: Run everywhere
- Category: [Security](https://wpide.com/library/category/security/)
- Tags: reports, updates, email
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/sec-weekly-security-summary/

## Code

```php
add_action( 'init', function () {
    if ( ! wp_next_scheduled( 'wpide_weekly_security_summary' ) ) {
        wp_schedule_event( strtotime( 'next monday 08:00' ), 'weekly', 'wpide_weekly_security_summary' );
    }
} );

add_action( 'wpide_weekly_security_summary', function () {
    if ( ! function_exists( 'get_plugins' ) ) {
        require_once ABSPATH . 'wp-admin/includes/plugin.php';
    }

    $core    = get_site_transient( 'update_core' );
    $plugins = get_site_transient( 'update_plugins' );
    $themes  = get_site_transient( 'update_themes' );
    $core_up = ! empty( $core->updates[0]->response ) && 'upgrade' === $core->updates[0]->response;
    $admins  = get_users( array( 'role' => 'administrator', 'fields' => array( 'user_login' ) ) );
    $new     = get_users( array( 'date_query' => array( array( 'after' => '1 week ago' ) ), 'fields' => 'ID', 'number' => 500 ) );
    $active  = (array) get_option( 'active_plugins', array() );

    $lines = array(
        'WordPress update available: ' . ( $core_up ? 'yes (' . $core->updates[0]->current . ')' : 'no' ),
        'Plugin updates pending: ' . ( empty( $plugins->response ) ? 0 : count( $plugins->response ) ),
        'Theme updates pending: ' . ( empty( $themes->response ) ? 0 : count( $themes->response ) ),
        'Inactive plugins installed: ' . max( 0, count( get_plugins() ) - count( $active ) ),
        'Administrator accounts (' . count( $admins ) . '): ' . implode( ', ', wp_list_pluck( $admins, 'user_login' ) ),
        'New users this week: ' . count( $new ),
        'Debug mode: ' . ( defined( 'WP_DEBUG' ) && WP_DEBUG ? 'ON - turn it off on a live site' : 'off' ),
    );

    if ( ! empty( $plugins->response ) ) {
        $lines[] = '';
        $lines[] = 'Plugins to update:';
        foreach ( $plugins->response as $file => $data ) {
            $lines[] = '  ' . $file . ' -> ' . ( isset( $data->new_version ) ? $data->new_version : '?' );
        }
    }

    wp_mail( get_option( 'admin_email' ), sprintf( '[%s] Weekly security summary', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) ), implode( "\n", $lines ) . "\n\nManage updates: " . admin_url( 'update-core.php' ) );
} );
```

## Notes

Update counts come from WordPress's own update checks, so no extra requests are made.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Weekly Security Summary Email" 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/
