# bbPress: Limit New Topics per Member per Day

> Caps how many new topics a member can start in 24 hours, which stops spammers and over-eager posters from flooding the forums.

- Type: PHP
- Runs: Run everywhere
- Category: [Users](https://wpide.com/library/category/users/)
- Tags: bbpress, spam, limits
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/bbpress-topic-flood-limit/

## Code

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

$wpide_bbp_topics_per_day = 5;

add_filter( 'bbp_new_topic_pre_content', function ( $content ) use ( $wpide_bbp_topics_per_day ) {
    $user_id = get_current_user_id();

    if ( ! $user_id || current_user_can( 'moderate' ) ) {
        return $content;
    }

    $recent = get_posts( array(
        'post_type'     => bbp_get_topic_post_type(),
        'post_status'   => 'any',
        'author'        => $user_id,
        'date_query'    => array( array( 'after' => '24 hours ago', 'column' => 'post_date_gmt' ) ),
        'numberposts'   => $wpide_bbp_topics_per_day,
        'fields'        => 'ids',
        'no_found_rows' => true,
    ) );

    if ( count( $recent ) >= $wpide_bbp_topics_per_day ) {
        bbp_add_error( 'wpide_bbp_flood', sprintf( '<strong>Error:</strong> You can start up to %d topics a day. Please try again tomorrow.', $wpide_bbp_topics_per_day ) );
    }

    return $content;
} );
```

## Notes

Replies are not limited. Moderators are exempt.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "bbPress: Limit New Topics per Member per Day" 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/
