WordPress Password Protected Pages / Posts Error Logging In Fixed

July 23rd, 2010 | 2 Comments | Posted in Hacks & Mods, Wordpress

I’m running WordPress 3 with Domain Mapping on one installation. The domain mapping plugin lets you map sub-blogs (www.mysite.com/blogone and www.mysite.com/blogtwo) to unique URLs (www.mysite.com and www.myothersite.com).

I recently discovered when I went to password protect a page on one of the sites that it totally failed. The password form would load, but when I entered the correct password it just reloaded the page with the password form still showing.

The culprit turned out to be in the wp-pass.php file. Line 16 uses PHP’s setcookie function to set a cookie good for 10 days that grants access to the page / post if you have entered the correct password. However, it uses the COOKIEPATH constant to define which directories (folders) on your site are accessible once the person is logged in. For me, COOIKEPATH was coming up as wordpress-mu (I originally started with that, then upgraded to WordPress 3). A simple fix was to edit the line to:

  1. <?php
  2. setcookie('wp-postpass_' . COOKIEHASH, $_POST['post_password'], time() + 864000, '/');
  3. ?>

Follow Discussion

2 Responses to “WordPress Password Protected Pages / Posts Error Logging In Fixed”

  1. Jerry Says:

    I am getting the same behavior out of password protected pages. You fix didn’t help. Any other ideas??

  2. James Says:

    Can you provide some details? What version of WordPress are you using? Link to the page that is showing the issue? I’d be happy to try and help you sort it out.

Leave a Reply