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


/ Published in: PHP
Save to your folder(s)

Thanks to Tummel.me

Works on newer (~3.4) versions of WP.


Copy this code and paste it in your HTML
  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. }

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.