0

I'm creating pages in a portal that are all available to the user but every page is password protected. The user will receive an email ea. month with the password for that months page to view the content.

By default, Wordpress does the following (this is from their codex page):

WordPress will only track one password at a time. Therefore, if two posts use two different passwords, entering the password for post A, then entering the password for post B means that revisiting post A (or any post which shares its password) will require the user to re-enter the password for post A.

My question is if there is a way to make it so multiple passwords are stored in the browser cookie so that when the user revisits post A (in the example above) they will not have to re-enter the password. Ideally, I'd like it to store all of the passwords for all of the separate password protected pages so that once the user enters the password the first time, they won't have to ever enter it again (unless of course they clear browser cookies).

Thanks for your help!

0

Rather than changing passwords on the posts/pages themselves, you could reset the users' passwords every month. You would set up your posts/pages/CPTs such that only logged-in users of a certain role could view the pages you want to protect, assign everyone that role, and email them their monthly password. That way, when they try to view a page, they're sent over to the login form; they must enter the current password to view any of the pages; and once they're logged in they can view all the protected content.

  • I appreciate the offer for a work-around, but I'm using a portal plugin that is already highly customized and entirely automated. The user is already logged in at this point so changing the password wouldn't provide a solution. – Jesse Apr 16 '18 at 18:56
0

On page load (template_redirect) you could check for a sent password in $_POST and save it to an extra cookie. Then you´d have to hook into https://developer.wordpress.org/reference/functions/post_password_required/ and return false if a password in your cookie fits.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.