Wordpress LScache Plugin: Password Protected Page
Last Updated on: Wed, 15 Apr 2026 00:00:02 Hi, I have site on a sub-domain which uses the WordPress built-in Password Protected page option. It also has a custom error message which displays when someone enters an incorrect password. The code that creates this custom error message is in the functions.php file and looks like the below: add_filter( the_password_form, wpse_71284_custom_post_password_msg ) / Add a message to the password form. @wp-hook the_password_form @param string $form @return string / function wpse_71284_custom_post_password_msg( $form ) // No cookie, the user has not sent anything until now. if ( ! isset ( $_COOKIE[ wp-postpass_ . COOKIEHASH ] ) ) return $form // Translate and escape. $msg = wp_kses( If you have trouble logging in or want further support, email email@domain.co.uk, your_text_domain ) // We have a cookie, but it doesnt match the password. $msg = $msg return $msg . $form Expand The issue Im having is sometimes the login stops working, if you enter an incorrect password the custom error message doesnt display and if you enter the correct password it doesnt display the content and just refreshes the page. However, if I do a Purge All Cache I can temporarily login successfully, but when I revisit the page after a certain period of time using a private browsing session the login stops working again. I have spoken to my host about this but they have been unable to resolve the issue. I can provide a URL to the page but would rather not post this online. Any help much appreciated. This topic was modified 4 years, 9 months ago by andyt1980. Can you check if the login page is cached? Try to disable cache login page temporarily for debug. I thought this but couldnt find anywhere in the plugin settings to specify disabling cache for a specific page? Incidentally its the home page that has the login. In Excludes tab, try Do Not Cache URIs Wasnt sure how to specify the homepage so just entered / then pressed save changes but this had no effect. Just a quick thing to add to that, since it is your homepage and you want to avoid pattern matching on your entire site, youll need to make sure you enter a string thats an exact match. For that, enter the exact path of your home page surrounded by ^ and $. For example, the path to your home page is probably / , and so youd enter: ^/$ ok added ^/$ but still no effect when visiting site in private browser session. Can you tell if the page is cached or not? Any header? Yes in the source code at the bottom it shows: Shall I try a Purge All Cache now that Ive added the exclude?. The problem is if I do that I will have to keep testing it for a few minutes or perhaps longer until it possibly stops working again. I have discovered if I log into the WordPress backend and then reload the homepage the login works correctly again. Once someone has logged into the backend it appears this also allows anyone else visiting the login page to login who previously couldnt. Are you caching logged in users? It may be that the password protection is working because the page is not cached for you. In answer to your earlier question, yes, you should Purge All any time you change the cache settings. Ok, Ive now turned off Cache Logged-in Users and Purged the cache again. Its currently still working for private and non-private browser sessions so I will have to keep checking to see if it continues to work. This seems to be fixed now. Although my host has also added the cookie wp-postpass_ to the do not cache cookie list here: LiteSpeed Cache Settings > [4] Excludes > Do Not Cache Cookies So not sure which setting has actually fixed it. I would say its probably the ^/$ exclude, since Do Not Cache Cookies doesnt use wildcards (like ). Either way, Im glad to hear its working! Thanks for the update. For the record, it turns out I was wrong. That field does support wildcards.
LiteCache Rush: Speed comes from using less, not from doing it faster
Reference