Use the ‘post_password_expires’ filter to return 0, which will expire the page’s password cookie at the end of the session.
If I could find that filter I would – please tell me where it is.
Note, the password entry field is not visible in the editor, either visually or code version
https://developer.ww.wp.xz.cn/reference/hooks/post_password_expires/
You can find nearly any WP core code by searching the Code Reference.
The post password field/form is automatically output when a theme template attempts to output the post content of a password protected post/page (unless a password cookie exists). The form’s HTML could be altered via the ‘the_password_form’ filter.
Thank you for that extra information. Sorry to be a nuisance but I still have a couple of concerns, a) if I modify wp-login.php and the theme is updated, will I lose the modification I made and b) although this is wp-login.php will it act on the admin login as well as the page password.
Thanks again
As it happens, page/post password submissions are also handled by wp-login.php, however they are handled by a separate part of wp-login.php that is unrelated to general back end user logins. The filter hook involved is also separate from back end user logins, so changing post/page cookie expiration will not affect back end logins.
If you add your custom code to a theme that is subject to periodic updates, then yes, you’d need to re-apply your code after any updates. Not a good approach. To protect your code from updates, you should either create a child theme or a custom plugin to contain your code. Unless altered theme templates are involved, plugins are easier to create than child themes. Creating your own plugin might sound ominous and intimidating, but a basic plugin is easy to create if you already have the PHP code you need to place within the plugin. You only need to know how to create a plain text file and place it on your WP server.
Thanks again, this is looking doable. I can easily create a text file, I just need to know where to place the result. Please can you provide a bit of guidance for the details
If your plugin will only be the one file, it can reside directly in /wp-content/plugins/. Multiple file plugins should have their own directory within /plugins/.
Be sure your file has a proper comment header. Then any necessary PHP code goes below it.
Once you think everything is ready to go, activate it like you would any other plugin. If it generates any PHP errors you will typically not be able to activate it. Be advised though that it’s possible for an error to slip through the activation check. If it does, it could possibly crash your site. This would be a rare occurrence, but if it does happen, to recover via FTP or your hosting file manager, rename your plugin file on the server to something else. Your site will then work properly again.
If there are any errors, you’ll want some clue about what went wrong. Check your server’s PHP error log for the clues.