# Paid Memberships Pro + bbPress: Forums for Members Only

> Lets only members with an active Paid Memberships Pro level open your bbPress forums, sending everyone else to the levels page.

- Type: PHP
- Runs: Frontend cl
- Category: [Memberships](https://wpide.com/library/category/memberships/)
- Tags: pmpro, bbpress, access
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/pmpro-bbpress-forums-for-members/

## Code

```php
if ( ! function_exists( 'pmpro_hasMembershipLevel' ) || ! function_exists( 'is_bbpress' ) ) {
    return;
}

$wpide_pmpro_forum_levels = array();

add_action( 'template_redirect', function () use ( $wpide_pmpro_forum_levels ) {
    if ( ! is_bbpress() || current_user_can( 'moderate' ) ) {
        return;
    }

    if ( pmpro_hasMembershipLevel( $wpide_pmpro_forum_levels ? $wpide_pmpro_forum_levels : null ) ) {
        return;
    }

    wp_safe_redirect( pmpro_url( 'levels' ) );
    exit;
} );
```

## Notes

List level IDs in $wpide_pmpro_forum_levels to allow only those levels, or leave it empty to allow any level.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Paid Memberships Pro + bbPress: Forums for Members Only" 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/
