Advanced Post Password

By Chema

0+ active installationsVersion 1.2

Remembers the password of your protected posts, lets administrators skip it and can hide the "Protected" prefix.

Description

WordPress asks for the password of a protected post every time the cookie of that post is not there, and every protected post has its own password. Advanced Post Password adds a few things on top of that behaviour, all optional:

The password is remembered per post. When a visitor types the password of a protected post, the plugin stores its own cookie for that post, separate from the WordPress one. The visitor can then browse that post and come back later without typing it again.

Administrators never see the password form. If you are logged in as an administrator, protected posts open directly, so you can check a draft or a client area without typing the password each time.

One master URL opens everything. Choose a URL and a password: whoever enters that password on that URL gets access to every protected post on the site, without typing the password of each one.

Cleaner titles. WordPress prepends “Protected:” and “Private:” to the titles of those posts. Two checkboxes remove those prefixes, on the site and in the browser tab.

How it works

The plugin listens to the standard password form of WordPress. When the form is submitted, it checks the password with the same hashing class WordPress uses and sets a cookie named after the post ID. On the next request, the post_password_required filter finds that cookie and skips the form.

The cookie is a hash, never the password in clear, and it expires after a year, the same way WordPress handles its own post password cookie. Cookies created by previous versions of the plugin are still accepted, so upgrading does not log anybody out.

Settings

Go to Settings > Post Password:

  • No admin password: administrators bypass the form on protected posts.
  • Removes protected prefix: hides “Protected:” from the titles.
  • Removes private prefix: hides “Private:” from the titles.
  • Master URL and Master URL password: the URL where the master password is accepted, and the password itself. Leave both empty to disable the feature.

The master URL should be a page that exists on your site, for example https://example.com/vip/. Visitors who open that page and enter the master password get access to every protected post.

Installation

  1. Install the plugin from the Plugins > Add New screen, or upload the advanced-post-password folder to the /wp-content/plugins/ directory.
  2. Activate the plugin through the Plugins menu in WordPress.
  3. Go to Settings > Post Password to choose the options.

FAQ

Do I lose the passwords when I update?

No. The plugin stores a hash of each password in its own cookie; the posts and their passwords are not touched at all. Cookies created by 1.1.2 and older are still read, so visitors do not have to type the password again after upgrading.

Does it protect the post content or only the form?

WordPress does the protecting: a post with a password returns its content only when the password has been provided. The plugin only adds alternative ways to prove that the password is known.

What happens if I leave the master URL empty?

The feature is off. The check for the master cookie is skipped and the plugin behaves exactly like the per post cookies.

Is the master password safe in the database?

It is stored as plain text in the options table, because it has to be compared with what the visitor types. Use a long, unique password, and only give it to people you trust with every protected post on the site.

Can I use it with a membership plugin?

Yes, it does not interfere with normal logins. Administrators keep bypassing the form, and logged in users with the right cookie see the content.

Does it work with a page builder or a custom theme?

Yes. The plugin uses the WordPress filters post_password_required, protected_title_format and private_title_format, so any theme that renders posts the standard way is covered.

Changelog

1.2

  • Fixed: the per post cookie was built from the referer, so it never matched the permalink when the site uses plain permalinks or the browser sends the URL without the trailing slash. The visitor typed the password and the form came back anyway. The cookie is now named after the post ID, and the cookies of previous versions are still read.
  • Fixed: the master URL was compared to the referer as an exact string, so https://example.com/vip and https://example.com/vip/ were different and the master password could silently fail. Both URLs are normalized before comparing.
  • Fixed: the master password was compared with ==, which in PHP treats two “magic hash” strings as equal. It now uses hash_equals().
  • Fixed: the master cookie was only checked for the option being different from false, not for being empty, so an empty master password could grant access to every protected post.
  • Fixed: $_SERVER['REQUEST_URI'] and $_POST['post_password'] were used without checking that they exist, which printed notices on some requests.
  • Fixed: the donation notice could not be dismissed, and the settings page printed an untranslated string without escaping.
  • Changed: the plugin no longer depends on jQuery for the admin notice.
  • Tested up to WordPress 7.1.
  • Improved the readme: description, how it works, settings and a proper FAQ.

1.1.2

  • Compatible with WordPress 6.4.

1.1.1

  • Compatible with WordPress 6.3.

1.0

  • Initial version.