• Resolved revstancline

    (@revstancline)


    I created a page with a link to a password protected page. When I click on the link I get the protected pages’ login asking for the password.

    However when I navigate to another page from the protected page that works. Now if I go back to the original page with the link for the protected page I run into a problem. When I click on the link for the protected page I get immediate access to the protected page. No login/password required page comes up.

    Is there a way to reset the password required screen to require a password each time someone wants to see the protected page?

    Thank you in advance for any help on this matter.

    The page I need help with: [log in to see the link]

Viewing 8 replies - 1 through 8 (of 8 total)
  • This is the default behavior for WordPress. When you enter the password, WP sets a cookie on that computer that remembers that you have access to the page in question. The cookie is set to expire after ten days, at which point you’ll be prompted for the password again.

    You can change this behavior. The quick and easy way is to use a plugin such as this one: https://www.ads-software.com/plugins/password-protection-expiration/

    The problem with using a plugin is that you are adding overhead to your server, plugins can represent a security risk (the plugin I linked to hasn’t been updated in two years), and they require a certain amount of maintenance.

    The alternative is to create a child theme and add some custom code to its functions.php file. This does not add as much overhead to your server, and tends to be a bit more secure (within reasons). But it does require a bit of technical knowledge.

    The following pages have some code which you can experiment with if you try the latter method:

    https://wordpress.stackexchange.com/questions/191369/how-to-make-page-post-password-protected-so-you-must-reenter-everytime-you-visit

    https://wordpress.stackexchange.com/questions/149313/set-session-time-limit-for-password-protected-posts

    If you run into problems, please let us know.

    Thread Starter revstancline

    (@revstancline)

    Okay but I have another question. I tried the plugin but no change after setting time to 60 seconds.

    I am not familiar with all the coding for a site so I was not sure where this code would be inserted to facilitate the change I am trying to acheive.

    function wpse_191369_post_password_expires() {
    return time() + 10; // Expire in 10 seconds
    }

    add_filter( ‘post_password_expires’, ‘wpse_191369_post_password_expires’ );
    That’s all you need.

    Does the actual code to be inserted start at the { or is it the whole expression starting with function? Will this handle pages or is it just for post?

    I’m a bit overwhelmed here so any help you can provide will be deeply appreciated.

    Does the actual code to be inserted start at the {

    If you created a child theme from scratch, your functions.php file would look like this to use that code:

    
    <?php
    
    function wpse_191369_post_password_expires() {
        return time() + 10; // Expire in 10 seconds
    }
    add_filter( 'post_password_expires', 'wpse_191369_post_password_expires' );
    

    That’s the entire content of the child theme’s functions.php file. Feel free to cut and paste.

    Keep in mind, you do need to create a child theme to make this work without a plugin. Have you done that step yet?

    • This reply was modified 7 years, 6 months ago by kjodle. Reason: Added "without a plugin."
    Thread Starter revstancline

    (@revstancline)

    First I want to thank you for being so kind and patient with me. Yes, I created the child theme as I am using the-wp so I created the-wp-child.

    I created a functions.php file but it is empty. What do I do from here?

    Thread Starter revstancline

    (@revstancline)

    I also created the style.css file but it is empty as well.

    I created a functions.php file but it is empty. What do I do from here?

    Copy the code I gave you above and paste it into your child theme’s functions.php file. It should be the only thing there. Save, and then refresh your browser.

    (Also, make sure you have selected your child theme as your site’s theme. I have made this mistake before. ?? )

    Thread Starter revstancline

    (@revstancline)

    Where and how do I make sure I have selected the child for the site theme?

    Thank you for all your help and understanding.

    Thread Starter revstancline

    (@revstancline)

    I think that fixes this issue. Now I am working on why it thinks the parent theme is not installed. Thank you for your help. You have done a great job and so appreciated.
    Blessings.
    Rev. Stan

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Password not resetting’ is closed to new replies.