[wp-trac] [WordPress Trac] #23412: Password protected pages - redirect after login
WordPress Trac
noreply at wordpress.org
Thu Feb 7 14:05:05 UTC 2013
#23412: Password protected pages - redirect after login
--------------------------+------------------------------
Reporter: dood_cro | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: 3.5.1
Severity: normal | Resolution:
Keywords: |
--------------------------+------------------------------
Changes (by SergeyBiryukov):
* component: Accessibility => General
Old description:
> 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
New description:
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
--
--
Ticket URL: <http://core.trac.wordpress.org/ticket/23412#comment:1>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list