• Resolved erdnapc

    (@erdnapc)


    Hello.

    From what I can tell, the support for the redirect_to parameter in the login link does not work. In digging into the implementation of the init_wtlwp() function in the public/class-wp-temporary-login-without-password-public.php file, I believe the issue is an improperly implementation of the login_redirect filter.

    The current implementation (plugin version 1.5.9) is passing the default redirection (the admin URL) as the first variable, a ternary test for $_REQUEST['redirect_to'] variable as the second variable, and then the $user variable as the third. Per the documentation at https://codex.www.ads-software.com/Plugin_API/Filter_Reference/login_redirect the second variable should be the URL the user is coming from, not the alternate redirect target.

    My proposal would be to change lines 88 and 89 from:

    
    $redirect_to     = admin_url();
    $redirect_to_url = apply_filters( 'login_redirect', $redirect_to, isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : '', $user ); // phpcs:ignore
    

    To

    
    $redirect_to     = isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : admin_url();
    $redirect_to_url = apply_filters( 'login_redirect', $redirect_to, false, $user ); // phpcs:ignore
    

    which correctly substitutes an alternate URL provided through the redirect_to parameter for the default admin URL value.

    Any thoughts on this or alternate reasons why appending &redirect_to=[encoded url] to my login links doesnt change the redirection?

    Thanks.
    -Andre

    • This topic was modified 6 years, 6 months ago by erdnapc. Reason: added code formatting to proposed changes
Viewing 5 replies - 1 through 5 (of 5 total)
  • Hello Andre,

    Thanks for pointing this out. We really appreciate it. We will fix this in the next release of Temporary Login Without Password plugin

    Curious to know in which scenario you want to redirect temporary user to a particular url?

    Normally, we give administrator, editor, author temporary access and they generally redirect to admin pages.

    Thread Starter erdnapc

    (@erdnapc)

    Thanks Malay.

    In my particular use-case the site in question was restricted to logged in users only (like a maintenance mode) during the development phase. After completing some work on a page we wanted to direct the client to view it, and wanted to send a login link that redirected to the page for review (to simplify them clicking the login link and then going back and clicking the page link). It’s certainly an uncommon option for the login links, but very helpful to have when needed.

    Thanks for the quick response, I look forward to seeing that fixed in the next release.

    -Andre

    Hello Andre,

    Thanks for your reply.

    I got your use case.

    Will release a new version(1.5.10) of Temporary Login Without Password plugin soon.

    Hello Andre,

    Just want to update you that, Temporary Login Without Password 1.5.10 is released now.

    The fix which you suggested is incorporated.

    Thread Starter erdnapc

    (@erdnapc)

    Thanks Malay, looks great!

    -Andre

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘redirect_to Doesn’t Work’ is closed to new replies.