• Resolved codebuddy

    (@codebuddy)


    We recently upgraded from version 6.3.12 -> 6.4.10 and noticed that when users logged in there where always redirected to their configured login url in the Redirection configuration (“Check this option to send the user to a custom location, specified by the textbox above.”).

    In 6.3.12 the value of the ‘redirect_to’ parameter passed to the login page would over ride this. From looking at the code in 6.3.12 this seems to be in custom-redirection.php on line 141:

    // If a redirect is requested, it takes precedence
    if ( ! empty( $request ) && admin_url() != $request && admin_url( 'profile.php' ) != $request )
        $redirect_to = $request;

    In 6.4.10 this code has been moved into get_redirect_for_user which doesn’t look at the value of the redirect_to parameter. It comes into login_redirect but is never passed to get_redirect_for_user.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Jeff Farthing

    (@jfarthing84)

    This was intentional. However, I could see how a setting to either always use the custom value or only use it when no redirection parameter is specified could be useful.

    Thread Starter codebuddy

    (@codebuddy)

    Hi Jeff, thanks for taking a look at this.

    Yes, it’s certainly useful for us. In our deployment, when users are checking out to pay for their products, we ask them to either login or create an account – when they do this we want them to return to the correct stage in the checkout, not the url configured (their account home page). Not doing so could lead to an increase in the number of abandoned carts etc.

    Plugin Author Jeff Farthing

    (@jfarthing84)

    Try this:

    
    function my_custom_login_redirect_filter( $redirect_to, $request ) {
        // If a redirect is requested, it takes precedence
        if ( ! empty( $request ) && admin_url() != $request && admin_url( 'profile.php' ) != $request ) {
            $redirect_to = $request;
        }
        return $redirect_to;
    }
    add_filter( 'login_redirect', 'my_custom_login_redirect_filter', 11, 2 );
    
    Thread Starter codebuddy

    (@codebuddy)

    Thanks Jeff, I’ll give that a whirl!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘login redirect_to paramter ignored in 6.4.10’ is closed to new replies.