Re: How to make a private community?
Thanks for your posts ^ ^
I’m finally getting round to setting up a private buddy press site.
I liked the looks of @Travel-Junkie‘s solution, but I’m having the same problem as @wordpresschina, I’m getting a infinite redirect loop. It seems that functions like bp_is_register_page() and bp_is_home() aren’t working correctly from @Travel-Junkie‘s function.
I changed it a little to:
function sh_walled_garden()
{
global $bp;
$uri = $_SERVER;
$allowed_uris[] = ”;
$allowed_uris[] = ‘/’;
for ($i=0; $i < count($allowed_uris); $i++) {
if ($allowed_uris[$i] === $uri) {
return;
}
}
if( ! is_user_logged_in() ) {
bp_core_redirect( $bp->root_domain);
}
}
add_action( ‘get_header’, ‘sh_walled_garden’ );
Where the $allowed_uris array is set by the programmer to allow access to certain public pages. If the user isn’t logged in and they are trying to access a private page, then they will be redirected to the home page (as that page will be public in my site setup and I don’t want people to be able to register through a sign up page.)
I’ll have to see how I get on with this solution for now…
Thanks for your help