BuddyDev

Search

Redirect To Page they were on before clicking signup

  • Participant
    Scott Tripp on #8205

    Hi there, we have the BuddyPress Auto Activate Autologin Redirect To Profile On Signup plugin installed and it works beautifully.

    Unfortunately we have twi user bases. One is just a user who would use their profile etc, but the other is a vendor who is taking out a paid listing.

    Both get to the sign up form in different ways.. Is there a code snippet that we could change that would allow them to redirect to where they were right before heading to the sign up form?

  • Keymaster
    (BuddyDev Team)
    Posts: 24211
    Brajesh Singh on #8206

    Hi Scott,
    Thank you for posting.
    I am not sure how to get the information on what page the user was before registration but I will help you with some example snippet that you may extend to work.

    
    /**
     * Filter where to redirect the user after account activation
     *
     * @param string $redirect_url user's profile url
     * @param int $user_id numeric user id
     *
     * @return string
     */
    function buddydev_filter_auto_redirect_url( $redirect_url, $user_id ) {
    
    	// You can filter the redirection based on user
    	// or you can change the $redirect_url to the appropriate value.
    // I suggest using the user_id for filtering approach
    
    	//$redirect_url = wp_get_referer(); //it will not work
    
    	return $redirect_url;
    
    }
    add_filter( 'bpdev_autoactivate_redirect_url', 'buddydev_filter_auto_redirect_url', 10, 2 );
    
    

    You can put this code in your bp-custom.php and modify it to work as per your requirements.

    Hope that helps.

    Regards
    Brajesh

The topic ‘Redirect To Page they were on before clicking signup’ is closed to new replies.

This topic is: not resolved