BuddyDev

Search

[Resolved] Logout and redirect to Register

  • Participant
    Level: Enlightened
    Posts: 66
    Jimmy Cheung on #42184

    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 2 years, 7 months ago by Jimmy Cheung. Reason: Add extra word
  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3050
    Ravi on #42201

    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
    Ravi

  • Participant
    Level: Enlightened
    Posts: 66
    Jimmy Cheung on #42211

    OMG 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,

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3050
    Ravi on #42226

    Hello Jimmy,

    Thank you for the acknowledgment. I am glad to help you.

    Merry Christmas…

    Regards
    Ravi

The topic ‘ [Resolved] Logout and redirect to Register’ is closed to new replies.

This topic is: resolved