Opened 12 years ago
Closed 11 years ago
#23412 closed defect (bug) (duplicate)
Password protected pages - redirect after login
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.5.1 |
Component: | Template | Keywords: | needs-patch |
Focuses: | Cc: |
Description (last modified by )
Hi,
I am using WP 3.5.1 and I have found out that after a successful login to a password protected page, WP won't redirect back.
This is because referrer is empty.
So I have modified page login script to have hidden "_wp_http_referer" field in form.
After that, login redirects back to page normally.
Here is my script:
function my_password_form() { global $post; $label = 'pwbox-'.( empty( $post->ID ) ? rand() : $post->ID ); $o = '<form class="protected-post-form" action="' . get_option( 'siteurl' ) . '/wp-login.php?action=postpass" method="post"> <p>' . __( "To view this protected post, enter the password below:" ) . '</p> <label for="' . $label . '">' . __( "Password:" ) . ' </label><input name="post_password" id="' . $label . '" type="password" size="20" /><input type="submit" name="Submit" value="' . esc_attr__( "Submit" ) . '" /> <input type="hidden" name="_wp_http_referer" value="'.get_permalink().'" /> </form> '; return $o; } add_filter( 'the_password_form', 'my_password_form' );
This functions returns empty URL to wp-login.php script:
function wp_get_referer() { $ref = false; if ( ! empty( $_REQUEST['_wp_http_referer'] ) ) $ref = $_REQUEST['_wp_http_referer']; else if ( ! empty( $_SERVER['HTTP_REFERER'] ) ) $ref = $_SERVER['HTTP_REFERER']; if ( $ref && $ref !== $_SERVER['REQUEST_URI'] ) return $ref; return false; }
I hope this helps.
I have tried this with all plugins disabled, and also on 20-12 theme, same error occurs.
Bye,
Dubravko
Change History (4)
Note: See
TracTickets for help on using
tickets.
I can't reproduce this in 3.5.1 or 3.6 trunk. Referer is usually pretty reliable on modern browsers. Sounds like a browser issue or maybe a server configuration. Could you provide more details on your setup & steps to reproduce?