Restrict BuddyPress and bbPress Pages to Logged-In Members

To make a BuddyPress community visible only to logged-in members, open Settings > BuddyPress > Options and set Community Visibility to Members Only. This setting exists since BuddyPress 12.0 and needs no code. It does not cover bbPress forums, so for those, or to send guests to your register page instead of a login form, add the snippet below.
We first published a snippet for this in 2015, for KLEO customers who wanted visitors to sign up before they could browse members. BuddyPress now does most of that job itself, so this is a rewrite for BuddyPress 12 and newer. Checked in November 2026 against BuddyPress 14.5.4 and bbPress 2.6.22.
The built-in setting (BuddyPress 12 and newer)
Community Visibility has two choices. Anyone is the default. Members Only restricts the community area to logged-in members: the member and group directories, every profile, every group and the activity feed.
A logged-out visitor who opens one of those pages sees the message “This community area is accessible to logged-in members only.” and a login form, in place of the page. The Register and Activate pages stay open, so people can still join.
Two things trip people up:
- The setting is global. There is no per-component switch in the admin yet, so you cannot keep groups public and hide profiles with it.
- It appears only when BuddyPress uses its own URL parser. With the BP Classic compatibility plugin active, BuddyPress falls back to the legacy parser and the option is not shown.
If you would rather send visitors to the WordPress login screen than show the message, BuddyPress has a filter for it. Add this to your child theme’s functions.php:
add_filter( 'bp_view_no_access_redirect_to_login_screen', '__return_true' );Lock forums too, or send guests to register
The snippet below is the 2015 idea, rewritten for current BuddyPress. A logged-out visitor on any BuddyPress page (except Register and Activate) or any bbPress page goes to your register page. It works with or without the Community Visibility setting, with BP Classic, and with bbPress on its own.
/** * Send logged-out visitors from BuddyPress and bbPress pages to the register page. */function sq_redirect_guests_to_register() { if ( is_user_logged_in() ) { return; }
$is_community = function_exists( 'is_buddypress' ) && is_buddypress() && ! bp_is_register_page() && ! bp_is_activation_page(); $is_forum = function_exists( 'is_bbpress' ) && is_bbpress();
if ( $is_community || $is_forum ) { wp_safe_redirect( wp_registration_url() ); exit; }}add_action( 'template_redirect', 'sq_redirect_guests_to_register' );What each call does:
is_buddypress()is true on any BuddyPress page: a directory, a profile, a group, the activity feed. It replaces the old! bp_is_blog_page()check, which tested the same thing the other way round.bp_is_register_page()andbp_is_activation_page()keep the sign-up pages reachable. Without them the redirect would loop.is_bbpress()comes from bbPress and is true on forum, topic, reply and forum search pages.wp_registration_url()is the WordPress register URL. BuddyPress filters it to its own register page, so you no longer hard-code/register/.template_redirectruns after WordPress and BuddyPress know which page was requested and before anything is printed, so the redirect is clean.
The function_exists() checks keep the site working if you deactivate one of the two plugins.
To lock only one of them, delete the other line: drop $is_forum to leave forums public, or drop $is_community to protect only the forums. If registration is closed on your site (Settings > General > Membership), replace wp_registration_url() with wp_login_url().
After you add it, open the site in a private window and click through members, a group, the activity feed and the forums. Then check that Register and Activate still load. If you use a page cache, clear it: a cached copy of a public page can still be served to guests.
When you need more than logged in or out
Logged in or not is a blunt rule. Two common next steps:
- Paid or tiered access. Paid Memberships Pro restricts pages, posts and categories by membership level. With KLEO, Theme options > Memberships restricts BuddyPress areas per level once Paid Memberships Pro is active (overview). The membership level guide shows the shortcodes for parts of a page.
- Parts of a page. In KLEO’s WPBakery builder, the Restrict Content element shows a block only to logged-in users or only to guests (how to). On Elementor pages, a visibility plugin does the same per widget; we compare the options in visibility plugins for user roles.
To close the whole site, not only the community, use a plugin such as Restricted Site Access from 10up instead of extending the snippet.
Our BuddyPress themes, KLEO, SeeKo and SweetDate, work with both the setting and the snippet. If you are starting a community from scratch, our guide on how to build a BuddyPress community site covers the rest of the setup.
Frequently asked questions
Can I make BuddyPress private without a plugin?
Yes. Since BuddyPress 12.0, go to Settings > BuddyPress > Options and set Community Visibility to Members Only. Logged-out visitors get a login form instead of the directories, profiles, groups and activity.
Does Community Visibility also hide bbPress forums?
No. It covers the BuddyPress community area. Forums at /forums/ are bbPress pages, so they stay public unless you add the snippet from this article or a forum privacy setting.
Why is the Community Visibility setting missing?
It only shows when BuddyPress uses its own URL parser. If the BP Classic plugin is active, BuddyPress runs the legacy parser and the setting is not there; use the snippet instead.
Can guests still register if the community is members-only?
Yes. The Register and Activate pages stay open, so new people can sign up and confirm their account.
How do I restrict BuddyPress by membership level instead?
Use Paid Memberships Pro. In KLEO, Theme options > Memberships restricts BuddyPress areas per level once Paid Memberships Pro is active.
