Last updated on

Sometimes you don’t want your entire WordPress website shown to all users. Luckily WordPress can password protect pages or posts using Core functionality. If you want users to register or hide from the public for privacy reasons, this can be a great solution.

To enable the WordPress password protected page feature, please follow these instructions:

  • Open the page or post you want to protect
  • In the Publish metabox there is a Visibility option
  • Choose Password protected in the dropdown
  • Enter the password you wish your users to enter to access the content
  • Click the blue Publish to save your changes

WordPress Password Protected Page Settings

Each page and post can have a unique password, or they can all be the same. With this method each user cannot have their own password. If you want unique passwords per user, you will need to have your users register. You can also use a plugin, which we will discuss later in this article.

Customize the Password Protected Page in WordPress

Next you may want to change the password protected message that displays. By default the message reads:

This content is password protected. To view it please enter your password below:

To change this message, you can use a plugin like WordPress Password Protect Page. It lets you edit the form in the WordPress Customizer and provides other useful options.

If you are selling memberships or access to your content, you’ll need a plugin like Paid Memberships Pro. It is widely used and provides a lot more tools to promote your paid content.

Those looking for a customizable PHP implementation can use custom code. In your child theme, or using a plugin like Code Snippets, you can modify the password form with a filter.

Here’s the code you can customize:

function my_custom_password_form() {
		global $post;
		$label = 'pwbox-' . ( empty( $post->ID ) ? rand() : $post->ID );
		$output = '
		<div class="boldgrid-section">
			<div class="container">
				<form action="' . esc_url( site_url( 'wp-login.php?action=postpass', 'login_post' ) ) . '" class="form-inline post-password-form" method="post">
					<p>' . __( 'This content is password protected. This is a custom message. To view it please enter your password below:' ) . '</p>
					<label for="' . $label . '">' . __( 'Password:' ) . ' <input name="post_password" id="' . $label . '" type="password" size="20" class="form-control" /></label><button type="submit" name="Submit" class="button-primary">' . esc_attr_x( 'Enter', 'post password form' ) . '</button>
	return $output;
add_filter('the_password_form', 'my_custom_password_form', 99);

We hope this helps you better work with password protected pages in WordPress. Please let us know your thoughts in the comments below.




   200+ Design Templates + 1 Kick-ass SuperTheme
   6 WordPress Plugins + 2 Essential Services

Everything you need to build and manage WordPress websites in one Central place.

Leave a Reply

Your email address will not be published. Required fields are marked *