# bbPress: Email Moderators About Posts Waiting for Approval

> Emails forum moderators and keymasters when a topic or reply lands in the pending queue (for example from Akismet or moderation rules), so nothing waits for days.

- Type: PHP
- Runs: Run everywhere
- Category: [Users](https://wpide.com/library/category/users/)
- Tags: bbpress, moderation, email
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/bbpress-notify-moderators-pending/

## Code

```php
if ( ! function_exists( 'bbp_get_pending_status_id' ) ) {
    return;
}

$wpide_bbp_pending_alert = function ( $post_id ) {
    if ( bbp_get_pending_status_id() !== get_post_status( $post_id ) || get_transient( 'wpide_bbp_pending_alert' ) ) {
        return;
    }

    set_transient( 'wpide_bbp_pending_alert', 1, 15 * MINUTE_IN_SECONDS );

    $emails = get_users( array( 'role__in' => array( 'bbp_keymaster', 'bbp_moderator' ), 'fields' => array( 'user_email' ), 'number' => 20 ) );
    $emails = wp_list_pluck( $emails, 'user_email' );

    if ( ! $emails ) {
        $emails = array( get_option( 'admin_email' ) );
    }

    wp_mail(
        $emails,
        'Forum posts are waiting for approval',
        sprintf( "A new forum post is waiting for moderation:\n%s\n\nAll pending topics: %s", get_permalink( $post_id ), admin_url( 'edit.php?post_type=' . bbp_get_topic_post_type() . '&post_status=' . bbp_get_pending_status_id() ) )
    );
};

add_action( 'bbp_new_topic', $wpide_bbp_pending_alert );
add_action( 'bbp_new_reply', $wpide_bbp_pending_alert );
```

## Notes

Sends at most one email every 15 minutes to avoid floods during spam waves.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "bbPress: Email Moderators About Posts Waiting for Approval" 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/
