Skip to main content
replaced http://wordpress.stackexchange.com/ with https://wordpress.stackexchange.com/
Source Link

Per these instructionsthese instructions I've cooked up a custom password protected page for some of the pages on my site:

    <?php if ( post_password_required() ) {
 
 
add_filter( 'the_password_form', 'custom_password_form' );
function custom_password_form() {
    global $post;
    $label = 'pwbox-'.( empty( $post->ID ) ? rand() : $post->ID );
    $o = '<form class="grey-form protected-post-form" action="' . get_option('siteurl') . '/wp-login.php?action=postpass" method="post">
    ' . __( "<P>
    PRIVATE. PLEASE USE THE YOU WERE GIVEN BLAH BLAH" ) . '
    <label class="pass-label" for="' . $label . '">' . __( "" ) . ' </label><input onChange="javascript:this.value=this.value.toLowerCase();" name="post_password" id="' . $label . '" type="password" style="background: #ffffff; border:1px solid #999; color:#333333; padding:10px;" size="20" /><input type="submit" name="Submit" class="button" value="' . esc_attr__( "Submit" ) . '" />
    </form>
    <div style="height:700px"/>
    ';
    return $o;
}
    
  echo get_the_password_form();

This is fine except if you test it with a wrong password it just reshows the form. No feedback to the user that he's put in a wrong password.

How can I feed back to my user that he's put in a wrong password?

Per these instructions I've cooked up a custom password protected page for some of the pages on my site:

    <?php if ( post_password_required() ) {
 
 
add_filter( 'the_password_form', 'custom_password_form' );
function custom_password_form() {
    global $post;
    $label = 'pwbox-'.( empty( $post->ID ) ? rand() : $post->ID );
    $o = '<form class="grey-form protected-post-form" action="' . get_option('siteurl') . '/wp-login.php?action=postpass" method="post">
    ' . __( "<P>
    PRIVATE. PLEASE USE THE YOU WERE GIVEN BLAH BLAH" ) . '
    <label class="pass-label" for="' . $label . '">' . __( "" ) . ' </label><input onChange="javascript:this.value=this.value.toLowerCase();" name="post_password" id="' . $label . '" type="password" style="background: #ffffff; border:1px solid #999; color:#333333; padding:10px;" size="20" /><input type="submit" name="Submit" class="button" value="' . esc_attr__( "Submit" ) . '" />
    </form>
    <div style="height:700px"/>
    ';
    return $o;
}
    
  echo get_the_password_form();

This is fine except if you test it with a wrong password it just reshows the form. No feedback to the user that he's put in a wrong password.

How can I feed back to my user that he's put in a wrong password?

Per these instructions I've cooked up a custom password protected page for some of the pages on my site:

    <?php if ( post_password_required() ) {
 
 
add_filter( 'the_password_form', 'custom_password_form' );
function custom_password_form() {
    global $post;
    $label = 'pwbox-'.( empty( $post->ID ) ? rand() : $post->ID );
    $o = '<form class="grey-form protected-post-form" action="' . get_option('siteurl') . '/wp-login.php?action=postpass" method="post">
    ' . __( "<P>
    PRIVATE. PLEASE USE THE YOU WERE GIVEN BLAH BLAH" ) . '
    <label class="pass-label" for="' . $label . '">' . __( "" ) . ' </label><input onChange="javascript:this.value=this.value.toLowerCase();" name="post_password" id="' . $label . '" type="password" style="background: #ffffff; border:1px solid #999; color:#333333; padding:10px;" size="20" /><input type="submit" name="Submit" class="button" value="' . esc_attr__( "Submit" ) . '" />
    </form>
    <div style="height:700px"/>
    ';
    return $o;
}
    
  echo get_the_password_form();

This is fine except if you test it with a wrong password it just reshows the form. No feedback to the user that he's put in a wrong password.

How can I feed back to my user that he's put in a wrong password?

Source Link
hawbsl
  • 500
  • 1
  • 11
  • 30

Styling my own password protected page, how to deal with wrong password?

Per these instructions I've cooked up a custom password protected page for some of the pages on my site:

    <?php if ( post_password_required() ) {
 
 
add_filter( 'the_password_form', 'custom_password_form' );
function custom_password_form() {
    global $post;
    $label = 'pwbox-'.( empty( $post->ID ) ? rand() : $post->ID );
    $o = '<form class="grey-form protected-post-form" action="' . get_option('siteurl') . '/wp-login.php?action=postpass" method="post">
    ' . __( "<P>
    PRIVATE. PLEASE USE THE YOU WERE GIVEN BLAH BLAH" ) . '
    <label class="pass-label" for="' . $label . '">' . __( "" ) . ' </label><input onChange="javascript:this.value=this.value.toLowerCase();" name="post_password" id="' . $label . '" type="password" style="background: #ffffff; border:1px solid #999; color:#333333; padding:10px;" size="20" /><input type="submit" name="Submit" class="button" value="' . esc_attr__( "Submit" ) . '" />
    </form>
    <div style="height:700px"/>
    ';
    return $o;
}
    
  echo get_the_password_form();

This is fine except if you test it with a wrong password it just reshows the form. No feedback to the user that he's put in a wrong password.

How can I feed back to my user that he's put in a wrong password?