Hi Yogi,
The register page on the site its already has a login area on the sidebar for members to login.
I DON’T want the homepage nor login page.
I actually want a function for visitors goes (redirect) to the register.php when anyone landed on the site.
Can you help me with a function and the correct login path for that?
Please help,
Thanks- This reply was modified 3 years ago by Jimmy Cheung. Reason: Add extra word
Hello Jimmy,
Thank you for the acknowledgment. Please use the following code:
/** * Make a WordPress site Private, works with/Without BuddyPress * * @author sbrajesh * @global string $pagenow * */ function buddydev_private_site() { // Do not restrict logged in users. if ( is_user_logged_in() ) { return; } //first exclude the wp-login.php //register //activate global $pagenow; // If we are here, the user is not logged in, so let us check for exclusion. // We selectively exclude pages from the list. // Are we on login page?. if ( $pagenow == 'wp-login.php' ) { return; } // Handle Special case of BuddyPress registration/Login. if ( function_exists( 'is_buddypress' ) && is_buddypress() ) { if ( bp_is_activation_page() || bp_is_register_page() ) { return; } } $redirect_url = wp_registration_url(); wp_safe_redirect( $redirect_url ); exit( 0 ); } add_action( 'template_redirect', 'buddydev_private_site', 0 );
It will redirect users to the register page except for wp-login.php, and ‘activate’
Please check and let me know if it helps.
Regards
RaviOMG Ravi,
YES YES AND YES!!! 🙂 🙂 🙂
This is an exactly what I wanted is to keep all visitors land on the register page. This way I have more chance for visitors to join.
OMG Ravi, Thank you SO MUCH for helping me with this function.
You have a wonderful Christmas!!!
Thank you again,
The topic ‘ [Resolved] Logout and redirect to Register’ is closed to new replies.