Support » Fixing WordPress » How to make password protected posts NOT remember the password

  • Resolved laowaichinese


    I’m making a web-based treasure hunt using WordPress password protected posts for each clue. (You enter the answer to the previous puzzle as the password to view the next one.) If some people share a computer, I want the site to ask them for the password each time they visit each post (or even hit “refresh”) so there’ll be no skipping ahead.

    Right now, there is a cookie that gets created when the correct password is entered. Then, if someone comes back to the password protected post later, they don’t have to input the password again.

    Here’s what I want to happen:
    1) visit post the first time, it says, “Enter password to view content” or whatever.
    2) you enter the password
    3) the page refreshes showing the content of the post
    —– all of the above happens right now —-
    4) the cookie is deleted
    5) if the user pushes Refresh or navigates away and comes back they see the message “Enter password to view content.”

    I was thinking that by just putting some sort of delete cookie function in the footer of my theme, it could load the page contents and then delete the cookie as soon as it’s loaded.

    Would that work? How would I do it?

    Any help anyone can offer would be greatly appreciated.


Viewing 2 replies - 1 through 2 (of 2 total)
  • acespedes


    Cambiar en el wp-pass.php el siguiente valor en la lĂ­nea 16,
    Change in wp-pass.php the follow code, on line 16:

    setcookie('wp-postpass_' . COOKIEHASH, $_POST['post_password'], time() + 864000, COOKIEPATH);

    Necesitas cambiar el valor de 864000 segundos, de acuerdo a las necesidades de tus usuarios.
    You need to change the value of 864000 seconds, according to yours users needed.

    En mi sitio, solo necesito que la recuerde 10 segundos.
    In my site, i just need to remember the cookie 10 seconds.

    Asi que debe quedar asi:
    So it should be as:

    setcookie('wp-postpass_' . COOKIEHASH, $_POST['post_password'], time() + 10, COOKIEPATH);




    Thanks SO much. That is exactly what I needed! Works great!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to make password protected posts NOT remember the password’ is closed to new replies.