[resolved] Broken redirect on wp_login_form() (6 posts)

  1. helgatheviking
    Posted 4 years ago #

    according to the codex the default redirect for wp_login_form() is:

    'redirect' => home_url( $_SERVER['REQUEST_URI'] )

    which seems like it ought to bring you right back to the page you are currently on.

    but if i log in from this example page:

    i get redirected to:

    which predictably 404s

    site.com/test is the home_url but then /test/product-category/widgets gets returned as the $_SERVER['REQUEST_URI']


  2. esmi
    Forum Moderator
    Posted 4 years ago #

    I thought this had been fixed: http://core.trac.wordpress.org/ticket/17243

  3. helgatheviking
    Posted 4 years ago #

    looking at the trac i think that is set for fixing in version 3.3 so either i have to start using the beta in production or still need some other stopgap for version 3.2.1

  4. helgatheviking
    Posted 4 years ago #

    additionally, i just moved to the 3.3 beta 3 on my local setup and that doesn't solve it, so perhaps it isn't fixed after all.

  5. helgatheviking
    Posted 4 years ago #

    looked at the diff in the trac ticket you linked me to. i took their new, changed value and filtered it in via the wp_login_form() args instead. seems to work for now. thanks!

    'redirect' => ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']

    edit to add:
    redirection works for me now in the 3.3beta if i don't define any redirect value

    so my full solution is to pass the correct argument for older versions of WP and nothing on 3.3

    if ( !version_compare( $wp_version, '3.3-beta3', '>=' ) ) {
    	$args = array ( 'echo'=>false,
    	'redirect' => ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']
    } else {
    	$args = array ( 'echo'=>false );

    thanks for pointing me in the right direction!

  6. helgatheviking
    Posted 4 years ago #

    can't seem to edit my post, but i should have removed the echo=>false for this example. i needed to return the value in my own theme, but if anyone tries to copy what i have above it won't print out anything.

Topic Closed

This topic has been closed to new replies.

About this Topic