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:
If you run into problems, please let us know.
]]>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?
]]>I created a functions.php file but it is empty. What do I do from here?
]]>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. ?? )
]]>Thank you for all your help and understanding.
]]>