Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Using the below code:

<?php if ( post_password_required() ) { ?>
    <form method="post" action="/wp-pass.php">
        <p>This content is password protected. To view it please enter your password below:</p>
        <input type="password" style="margin:10px 0;" size="20" id="pwbox-<?php the_ID(); ?>" name="post_password"/></label><br/>
        <input type="submit" value="Submit" name="Submit"/></p>
    </form>
<?php } else { ?>
    // echo out all of the post content
<?php } ?>

worked to hide specific content behind the Wordpress password protected functionality.

However, this has stopped working. The cookie is still being set and I can see it in the browser settings, but the function has stopped recognizing that the correct cookie is present and just reloads the page asking for the password again.

I don't use this functionality a lot, so it's hard to say wehen it stopped working exactly, but it could be related to upgrading Wordpress to the most recent release. Would that make sense?

UPDATE:

Here's the exact cookie content:

Name:   wp-postpass_xxxxxxxxxxxxxxxxxxxxx
Content:    secret
Domain: www.domain.com
Path:   /
Send for:   Any kind of connection
Accessible to script:   Yes
Created:    Monday, June 25, 2012 11:55:26 AM
Expires:    Thursday, July 5, 2012 11:55:25 AM

As you can see, the cookie contains the correct password content but the function has stopped recognizing this as being correct or valid.

UPDATE #2

Removed the testing URL now that the solution has been posted.

share|improve this question
    
I'm having this same problem after a 3.4 upgrade... –  Drew Baker Jun 26 '12 at 4:49
add comment

1 Answer 1

up vote 5 down vote accepted

Figured it out!

The new version of WordPress (3.4) changed the way the password protected pages worked.

This should work for you now:

    <?php if ( post_password_required() ) { ?>
    <form method="post" action="/wp-login.php?action=postpass">
        <p>This content is password protected. To view it please enter your password below:</p>
        <input type="password" style="margin:10px 0;" size="20" id="pwbox-<?php the_ID(); ?>" name="post_password"/></label><br/>
        <input type="submit" value="Submit" name="Submit"/></p>
    </form>
<?php } else { ?>
    // echo out all of the post content
<?php } ?>

I changed your line "/wp-pass.php" to the new "wp-login.php?action=postpass" way.

share|improve this answer
    
absolutely brilliant and thanks, been banging my head against this functionality for entirely too long. well done. –  chazbeaner Jun 26 '12 at 17:36
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.