Re: Protecting Buddypress pages from non-logged in users.
Another simpler approach would be to created a bp-custom.php and place it in the plugins directory and add the following code
`<?php
function bp_guest_redirect() {
global $bp;
if ( bp_is_activity_component() || bp_is_groups_component() /*|| bbp_is_single_forum()*/ || bp_is_forums_component() || bp_is_blogs_component() || bp_is_page( BP_MEMBERS_SLUG ) ) {
// enter the slug or component conditional here
if(!is_user_logged_in()) { // not logged in user
wp_redirect( get_option(‘siteurl’) . ‘/register’ );
} // user will be redirect to any link to want
}
}
add_filter(‘get_header’,’bp_guest_redirect’,1);
?>`
This code will work to hide buddypress pages and group forums as is, if your using sitewide forums in line 4 remove the comments around:
|| bbp_is_single_forum()
Save and refresh. Works in current versions.