btw, your plugin here would redirect anybody in any situation to the registration page,… even google etc… i’m not sure this logic is good… let people browse your site, they will register if they see fit.
btw, your plugin here would redirect anybody in any situation to the registration page,… even google etc…
That’s not quite correct -Â only non-logged-in users are being redirected :p
let people browse your site, they will register if they see fit.
Agreed, partially at least: I’ve been running a BP community a while ago where I used a similar snippet: Guests could browse the site freely as long as they did not try to access members’ profiles. If they did, they were redirected to the registration page. Helped a whole lot to generate registrations -Â with a surprisingly low percentage of “dead accounts”.
@Wilbrot, you have the example of a well managed community…
Can i enter this thread with a question:
I want my network only be visibe for logged in users. i put the following code in bp-custom.php but it leads to a redirct loop and i don’t see the mistake:
function restrict_access() {
global $bp, $bp_unfiltered_uri;
if (!is_user_logged_in() ) {
bp_core_redirect( $bp->root_domain . '/' . BP_REGISTER_SLUG );
}
}
add_action( 'wp', 'restrict_access', 3 );
Any hint for me?
Don’t know how BP_REGISTER_SLUG behaves, but have you tried
bp_core_redirect( $bp->root_domain . '/register' );
or
bp_core_redirect( get_bloginfo( 'siteurl') . '/register' );
?
Just figured out the solution. I forgot to exclude BP_REGISTER_SLUG from (!is_logged_in):
This solution works for me (put it in bp-custom.php)
function restrict_access() {
global $bp, $bp_unfiltered_uri;
if (!is_user_logged_in() && (BP_REGISTER_SLUG != $bp->current_component )) {
//bp_core_redirect( $bp->root_domain );
bp_core_redirect( $bp->root_domain . '/' . BP_REGISTER_SLUG );
}
}
add_action( 'wp', 'restrict_access', 3 );
How do i redirect members when they login to a new BP page (page i create??