# Daily Digest of Comments Awaiting Moderation

> Replaces the one-email-per-comment moderation notices with a single daily email listing every comment waiting for approval, with a link to the moderation screen.

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

## Code

```php
$wpide_digest_hour = 8; // Hour of the day (0-23, site time).

add_filter( 'notify_moderator', '__return_false' );

add_action( 'init', function () use ( $wpide_digest_hour ) {
    if ( wp_next_scheduled( 'wpide_pending_comments_digest' ) ) {
        return;
    }
    $next = new DateTime( 'today ' . $wpide_digest_hour . ':00', wp_timezone() );
    if ( $next->getTimestamp() <= time() ) {
        $next->modify( '+1 day' );
    }
    wp_schedule_event( $next->getTimestamp(), 'daily', 'wpide_pending_comments_digest' );
} );

add_action( 'wpide_pending_comments_digest', function () {
    $comments = get_comments( array( 'status' => 'hold', 'type' => 'comment', 'number' => 50, 'orderby' => 'comment_date_gmt', 'order' => 'DESC' ) );

    if ( ! $comments ) {
        return;
    }

    $total = (int) get_comments( array( 'status' => 'hold', 'type' => 'comment', 'count' => true ) );
    $lines = array( sprintf( '%d comment(s) are waiting for your approval:', $total ), '' );

    foreach ( $comments as $comment ) {
        $lines[] = sprintf( '• %s on "%s": %s', $comment->comment_author, wp_strip_all_tags( get_the_title( $comment->comment_post_ID ) ), wp_html_excerpt( wp_strip_all_tags( $comment->comment_content ), 120, '…' ) );
    }

    $lines[] = '';
    $lines[] = 'Moderate them: ' . admin_url( 'edit-comments.php?comment_status=moderated' );

    wp_mail( get_option( 'admin_email' ), sprintf( '[%s] %d comment(s) awaiting moderation', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ), $total ), implode( "\n", $lines ) );
} );
```

## Notes

Sent at the hour set at the top (site time) only when comments are waiting; goes to the admin email address.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Daily Digest of Comments Awaiting Moderation" 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/
