Jun
17
2012
 

WordPress 3.4 Custom Password Form

Are your password protected posts and pages broken since upgrading to WordPress 3.4?

Here is a little tip for anyone out there who may be using a custom password form to protect individual pages and posts. WordPress has this functionality built into its core but it is possible to customize the wording and look of your form. If you aren’t able to get into password protected posts anymore, you likely have a custom password form.

This post isn’t a long description of how to make custom password forms, rather a helpful tip to fix your password protected posts and pages if they are no longer accessible since upgrading to WordPress 3.4.

The core of the problem is that WordPress 3.4 has deprecated the use of wp-pass.php which was used in many custom password forms and replaced it with wp-login.php. Below is what a custom password form function is likely to look like, at least it’s what mine looks like:

// Custom password protected message / form
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="protected-post-form" action="' . get_option('siteurl') . '/wp-pass.php action=postpass" method="post">
' . __( "<h2>Enter Password</h2> 
<p>This proposal is password protected. To view it please enter your password below:</p>" ) . '
<label for="' . $label . '">' . __( "Password:" ) . ' </label><input name="post_password" id="' . $label . '" type="password" size="20" /><input type="submit" class="submit" name="Submit" value="' . esc_attr__( "Submit" ) . '" /> </form> 
';
return $o;
}

The first trick is finding where in your theme files that bit of code might be located. It could be in the functions.php file or  in its own php file somewhere in your theme. Once you find it though, if you
replace wp-pass.php with wp-login.php?action=postpass you should fix your problem. At least that’s how I updated my custom themes.

Comments
34 Comments
  1. Theleisurehour June 20, 2012 at 11:42 am #

    This worked for me, thank you VERY much!

    • gsibert June 20, 2012 at 9:20 pm #

      Glad it helped out!

  2. moritz June 21, 2012 at 3:20 am #

    thanks a lot. worked pefectly.

    • gsibert June 22, 2012 at 8:23 am #

      You’re welcome. Some day, and that day may never come, you will find a fix to some WordPress issue and you will share it with the world too. <– Just watched the Godfather 🙂

  3. Andrew June 23, 2012 at 2:29 pm #

    Thanks dude. Saved me a LOT of frustration.

  4. Ciril Mathew June 23, 2012 at 8:14 pm #

    this works for those who use IE. Its still broken with users using Google Chrome and Firefox

    • gsibert June 23, 2012 at 8:20 pm #

      I use Chrome, FF, IE, Safari & Opera, they all work… This has nothing to do with browser compatibility, only how WP internally handles passwords.

  5. Elton Godschalk June 26, 2012 at 6:25 am #

    Saved me a lot of time and frustration! Thanks!

  6. Elizabeth June 26, 2012 at 2:19 pm #

    This worked! Thank you so so much.

  7. Trond July 22, 2012 at 11:32 am #

    Yes, thanks!!!

  8. Evan July 24, 2012 at 1:16 pm #

    After nearly an hour of Googling I finally found the info that I needed! Thank you SO much!

  9. Steve August 4, 2012 at 8:58 am #

    At first I thought the problem had something to do with moving the site with backupbuddy. But then after finding your solution, I realized I had updated the website to WordPress 3.4 (after migrating) and yes indeed, the theme had it’s own password form.
    Thank you so much for posting your solution!

    • gsibert August 4, 2012 at 9:15 pm #

      Glad it helped out, keep on WordPressing!

  10. Géza Mikló August 6, 2012 at 12:34 am #

    This change was really a bad idea. All older themes should be revised now.

  11. Roy Kung August 10, 2012 at 3:42 am #

    You are my savior. thanks!!!!

  12. Jeremy August 17, 2012 at 2:03 am #

    Thank You SO MUCH! I had a hunch it was the update, but I had no idea how to fix it until now. You rock! Very helpful 🙂

  13. david September 6, 2012 at 4:29 am #

    Thank you very much man, it was really helpful to me and save a lot of time…

  14. Sagi Shrieber October 16, 2012 at 1:45 am #

    WOW! You saved me!!!! Thanks a lot for this post!

  15. Bilbo November 2, 2012 at 12:47 pm #

    Thank you very much

  16. Amy November 16, 2012 at 9:56 am #

    This is great advice, my problem is, is that I cannot find where those functions are at all. It’s like the option to password protect my posts is just gone! I have searched and searched, even looking in different themes for any sign of “wp-pass.php” and it is nowhere! I’ve basically created my whole site myself, so I know what I’m doing but I feel like a complete idiot here. Where can I even change “wp-pass.php” ???

    • gsibert November 20, 2012 at 7:43 am #

      Did you have this functionality and it just disappeared with a WordPress update? What theme are you using?

    • Vaclav January 2, 2014 at 4:45 am #

      I found it in root/wp-content/themes/XXX/includes

  17. icapricorn April 16, 2013 at 11:47 am #

    Thank you! That fixed my problem. I’m using WordPress 3.5.1

  18. goodhand May 23, 2013 at 3:52 pm #

    AWESOME, saved me working late delving into the core files, legend!

  19. Sean_McKee June 18, 2013 at 6:47 am #

    Thank you!!

  20. Jess Johnston June 26, 2013 at 3:24 pm #

    Thanks! This helped a LOT. 🙂

  21. Sean Gleason July 1, 2013 at 4:11 pm #

    Thanks for the post. To get it to work for WP Version 3.5.2 you need to change

    /wp-pass.php action=postpass

    To

    /wp-login.php?action=postpass

    Worked for me

  22. Luke February 6, 2014 at 2:59 am #

    Finally! Thankyou!

  23. rano June 26, 2015 at 6:16 am #

    i found functions.php file but could not find wp-pass.php , where is it?? help me

    thanks

    • Grady Sibert June 26, 2015 at 7:10 am #

      Hi Rano, you’re not actually looking for the file wp-pass.php but a reference to it. Probably the easiest way to find it in your theme is to download the theme directory to your local computer (if you don’t have it there already) and search the theme folder for wp-pass.php. That should give you a list of files that contain that text… at least that’s how I would look for it. Strange though, this is a rather old problem. How long has it been since you updated WordPress?

  24. Jessica June 23, 2020 at 7:56 am #

    THANK YOU! This was the solution I was looking for!

    • Grady Sibert June 23, 2020 at 8:20 am #

      Wow, 8 years later and still helpful. So glad to hear 🙂

Trackbacks/Pingbacks

  1. Password Protect & Custom Password Form 404 « PixelPress Wiki - August 6, 2012

    […] Taken from: https://tummel.me/wordpress-3-4-custom-password-form/ […]

  2. Password Protection Trouble ~ ian-scott.net - November 20, 2012

    […] functionality and my messing WordPress must have upgraded. This changed how passwords are handled (explanation is here for example). In short, instead of the password form passing to wp-pass.php it must pass to […]

Leave a Reply