# Weekly Site Activity Summary by Email

> Emails the site admin every Monday with last week's numbers: new posts, comments, pending items and new users, so you keep an eye on the site without logging in.

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

## Code

```php
$wpide_summary_hour       = 9;
$wpide_summary_recipients = array(); // Extra addresses; the admin email is always included.

add_action( 'init', function () use ( $wpide_summary_hour ) {
    if ( wp_next_scheduled( 'wpide_weekly_summary' ) ) {
        return;
    }
    $next = new DateTime( 'monday this week ' . $wpide_summary_hour . ':00', wp_timezone() );
    if ( $next->getTimestamp() <= time() ) {
        $next->modify( '+1 week' );
    }
    wp_schedule_event( $next->getTimestamp(), 'weekly', 'wpide_weekly_summary' );
} );

add_action( 'wpide_weekly_summary', function () use ( $wpide_summary_recipients ) {
    $since = gmdate( 'Y-m-d H:i:s', time() - WEEK_IN_SECONDS );

    $posts = new WP_Query( array( 'post_type' => 'post', 'post_status' => 'publish', 'date_query' => array( array( 'after' => $since, 'column' => 'post_date_gmt' ) ), 'fields' => 'ids', 'posts_per_page' => 1 ) );
    $users = new WP_User_Query( array( 'date_query' => array( array( 'after' => $since, 'column' => 'user_registered' ) ), 'fields' => 'ID', 'number' => 1, 'count_total' => true ) );

    $stats = array(
        'Posts published'             => (int) $posts->found_posts,
        'Comments approved'           => (int) get_comments( array( 'status' => 'approve', 'count' => true, 'date_query' => array( array( 'after' => $since, 'column' => 'comment_date_gmt' ) ) ) ),
        'Comments waiting'            => (int) wp_count_comments()->moderated,
        'Posts waiting for review'    => (int) wp_count_posts( 'post' )->pending,
        'New users'                   => (int) $users->get_total(),
    );

    $lines = array( 'Here is what happened on ' . home_url() . ' in the last 7 days:', '' );
    foreach ( $stats as $label => $value ) {
        $lines[] = sprintf( '%-28s %d', $label . ':', $value );
    }
    $lines[] = '';
    $lines[] = 'Dashboard: ' . admin_url();

    $to = array_merge( array( get_option( 'admin_email' ) ), array_filter( $wpide_summary_recipients, 'is_email' ) );
    wp_mail( $to, sprintf( '[%s] Weekly summary', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) ), implode( "\n", $lines ) );
} );
```

## Notes

Sent on Monday at the hour set at the top (site time); add more recipients to the list.

## How to use it

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