0

does anyone know a quick and simple way to also give access to a WordPress standard password-protected page if there is an existing third party cookie on the user's machine? I need to see if someone is already logged into another platform, and if so give them access WITHOUT having to also enter the WordPress page password.

In other words, for a user to view a specific password-protected page, they have to satisfy one of two criteria.

EITHER: The user has entered the WordPress page password (and so there is a WordPress generated cookie on their machine) OR There is a third party cookie, whose filename and content are known, already existing on the user's machine.

Any hints and help on the best / simplest way to achive this will be gratefully received!

1

The check is handled by post_password_required(), which seems to be incredibly inconvenient to override.

The only way I can think of is early during load:

  1. Check if there is a valid WP cookie (if there we are done).
  2. Check if there is valid external cookie (if not we are done).
  3. If there is then generate a WP cookie value and stuff it into $_COOKIE global in expected place.
  • Thanks for the pointer Rarst - where would I need to put those checks? – user91262 Mar 28 '16 at 9:53
  • If I am not mistaken password is usually checked when content (or related things like comments) is being output, so timing of setting this up would need to preferably be before page output (such as init hook for example). – Rarst Mar 28 '16 at 15:07

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.