Skip to:
Content
Pages
Categories
Search
Top
Bottom

Redirecting to different page if user is already logged in

  • @samurdhilbk

    Participant

    When I try to go to the Register page while already logged-in, BuddyPress redirects to the home page. How can I change where it redirects to, in such an occasion?

    WordPress version – 4.7.2
    BuddyPress version – 2.7.4

Viewing 4 replies - 1 through 4 (of 4 total)
  • @sbrajesh

    Participant

    Hi, you can put the following code in your bp-custom.php

    
    /**
     * BuddyPress Logged In User redirection on Registration page
     *
     */
    function buddydev_loggedin_register_redirect( $redirect ) {
    
    	//you can do a lot here
    	//if you want to redirect based on profile field, member types or roles, you can do so
    	//$user_id = bp_loggedin_user_id();
    
    	//send to profile
    	//$redirect = bp_loggedin_user_domain();
    
    	// or you can simply hard code it
    	//$redirect = "http://yoursite.com/example-page"
    
    	return $redirect;
    }
    add_filter( 'bp_loggedin_register_page_redirect_to', 'buddydev_loggedin_register_redirect' );
    
    

    Now uncomment on of the //$redirect block or you can put your own link.

    Hope that helps.

    @samurdhilbk

    Participant

    That worked perfectly! Thanks! What if I want to disable the redirect entirely?

    @sbrajesh

    Participant

    You are welcome!

    I am not sure what do you mean by disabling the redirect. What purpose will it serve to show the registration page to the already logged in user? At the moment, if you want to show registration form to the logged in user, It can be done with some custom code, but it is not advisable.

    Regards
    Brajesh

    @samurdhilbk

    Participant

    I am developing a rather different membership scheme. I figured it out anyway. Thanks for the help Brajesh!

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.
Skip to toolbar