WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] How to make password protected posts NOT remember the password (3 posts)

  1. laowaichinese
    Member
    Posted 6 years ago #

    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.

    Thanks

  2. acespedes
    Member
    Posted 5 years ago #

    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);

  3. laowaichinese
    Member
    Posted 5 years ago #

    acespedes,

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

Topic Closed

This topic has been closed to new replies.

About this Topic