# bbPress: Stop Replies to Old, Inactive Topics

> Hides the reply form on topics with no activity for a set number of days and shows a note instead, which prevents necro-posting and old-thread spam.

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

## Code

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

// Days without activity before replies stop.
$wpide_bbp_lock_days = 180;

$wpide_bbp_is_stale = function ( $topic_id ) use ( $wpide_bbp_lock_days ) {
    $last = get_post_meta( $topic_id, '_bbp_last_active_time', true );

    return $last && time() - strtotime( $last . ' UTC' ) > $wpide_bbp_lock_days * DAY_IN_SECONDS;
};

add_filter( 'bbp_current_user_can_access_create_reply_form', function ( $can ) use ( $wpide_bbp_is_stale ) {
    if ( ! $can || current_user_can( 'moderate' ) || ! bbp_is_single_topic() ) {
        return $can;
    }

    return $wpide_bbp_is_stale( bbp_get_topic_id() ) ? false : $can;
} );

add_action( 'bbp_template_after_single_topic', function () use ( $wpide_bbp_is_stale ) {
    if ( ! current_user_can( 'moderate' ) && $wpide_bbp_is_stale( bbp_get_topic_id() ) ) {
        echo '<div class="bbp-template-notice"><ul><li>This topic has been quiet for a long time, so replies are closed. Feel free to start a new topic.</li></ul></div>';
    }
} );
```

## Notes

Topics are not changed in the database; the reply form simply stops showing. Moderators can still reply.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "bbPress: Stop Replies to Old, Inactive Topics" 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/
