Redirect if not logged in and not on register page
-
So far I have
<?php function my_redirecter() { global $bp; if ( ! is_user_logged_in()&& BP_REGISTER_SLUG == $bp->current_component) { wp_redirect( home_url() . '/register/'); exit(); } else { } } add_action( 'init', 'my_redirecter' ); ?>
I want to redirect to register page if not logged in AND not already on register page (otherwise I have infinite redirects).
It seems that the $bp->current_component part isn’t right. My slug inside wp-config.php looks like:
define ( ‘BP_REGISTER_SLUG’, ‘register’ );
Any tips?
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘Redirect if not logged in and not on register page’ is closed to new replies.