Daily Digest of New User Registrations
Replaces the "New user registration" email WordPress sends for every sign-up with one daily email listing all new users, their role and email address.
Opens WPIDE on
Code
$wpide_users_digest_hour = 8;
add_filter( 'wp_send_new_user_notification_to_admin', '__return_false' );
add_action( 'init', function () use ( $wpide_users_digest_hour ) {
if ( wp_next_scheduled( 'wpide_new_users_digest' ) ) {
return;
}
$next = new DateTime( 'today ' . $wpide_users_digest_hour . ':00', wp_timezone() );
if ( $next->getTimestamp() <= time() ) {
$next->modify( '+1 day' );
}
wp_schedule_event( $next->getTimestamp(), 'daily', 'wpide_new_users_digest' );
} );
add_action( 'wpide_new_users_digest', function () {
$users = get_users( array(
'date_query' => array( array( 'after' => gmdate( 'Y-m-d H:i:s', time() - DAY_IN_SECONDS ), 'column' => 'user_registered' ) ),
'number' => 200,
'orderby' => 'registered',
'order' => 'DESC',
) );
if ( ! $users ) {
return;
}
$lines = array( sprintf( '%d new user(s) registered in the last 24 hours:', count( $users ) ), '' );
foreach ( $users as $user ) {
$lines[] = sprintf( '• %s <%s> – %s', $user->user_login, $user->user_email, implode( ', ', (array) $user->roles ) );
}
$lines[] = '';
$lines[] = 'All users: ' . admin_url( 'users.php' );
wp_mail( get_option( 'admin_email' ), sprintf( '[%s] %d new user(s)', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ), count( $users ) ), implode( "\n", $lines ) );
} );
Notes
Needs WordPress 6.1 or later, users still get their own welcome email, and nothing is sent on days without new registrations.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.