Posted By

adambundy on 11/15/12


Tagged


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

adambundy


WordPress - change the password request form on password-protected posts and pages


 / Published in: PHP
 

URL: http://tummel.me/wordpress-3-4-custom-password-form/

Thanks to Tummel.me

Works on newer (~3.4) versions of WP.

  1. // add to functions.php
  2.  
  3. add_filter( 'the_password_form', 'custom_password_form' );
  4. function custom_password_form() {
  5. global $post;
  6. $label = 'pwbox-'.( empty( $post->ID ) ? rand() : $post->ID );
  7. $o = '<form class="protected-post-form" action="' . get_option('siteurl') . '/wp-login.php?action=postpass" method="post">
  8. ' . __( "MESSAGE TO APPEAR ABOVE THE FORM" ) . '
  9. <label class="pass-label" for="' . $label . '">' . __( "PASSWORD:" ) . ' </label><input name="post_password" id="' . $label . '" type="password" size="30" /><input type="submit" name="Submit" class="button" value="' . esc_attr__( "Submit" ) . '" />
  10. </form> MESSAGE TO APPEAR BELOW FORM';
  11. return $o;
  12. }

Report this snippet  

You need to login to post a comment.