# bbPress: Block Links in Posts From New Members

> Stops members who joined in the last few days from posting links in forum topics and replies, with a clear message explaining why.

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

## Code

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

$wpide_bbp_link_days = 7;

$wpide_bbp_check_links = function ( $content ) use ( $wpide_bbp_link_days ) {
    $user = wp_get_current_user();

    if ( ! $user->exists() || current_user_can( 'moderate' ) ) {
        return $content;
    }

    $is_new = time() - strtotime( $user->user_registered . ' UTC' ) < $wpide_bbp_link_days * DAY_IN_SECONDS;

    if ( $is_new && preg_match( '#(https?://|www\.|<a\s)#i', $content ) ) {
        bbp_add_error( 'wpide_bbp_links', sprintf( '<strong>Error:</strong> New members can post links after %d days. Please remove the link and try again.', $wpide_bbp_link_days ) );
    }

    return $content;
};

add_filter( 'bbp_new_topic_pre_content', $wpide_bbp_check_links );
add_filter( 'bbp_new_reply_pre_content', $wpide_bbp_check_links );
```

## Notes

Moderators and keymasters can always post links.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "bbPress: Block Links in Posts From New Members" 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/
