Password Protect WordPress (PPWP) enables you to protect not only the entire page but also partial content. It comes in handy when you want to show a part of content to engage the readers while hiding the rest for paid users.
- Password Protect WordPress Lite version 1.2.1 and greater
In this article, we will walk you through the sections below:
- How to Password Protect a Section of Content
- Features in Brief
- Optional Attributes
- Known Issues and Solutions
How to password protect a section of content
Simply wrap the section you need to protect with the shortcode below:
[ppwp passwords= "password1 password2"] Your content [/ppwp]
Once done, click on Publish button and you will see something as below:
Our plugins support multiple passwords per shortcode by default. Users enter “password1” or “password2” to access your protected area.
Each password is case-sensitivity and no more than 100 characters, but doesn’t contain [, ], “, ‘ and space characters (as WordPress’ rule).
It’s important to note that “passwords” attribute is required. If not, you will see the error message: [ppwp] Empty content, invalid attributes or values instead of password form.
Since version 1.1.5, PPWP Pro makes it easier to protect a part of content by using built-in elements in Page Builders.
Features in brief
- Support Pages & Posts
- Since version 1.1.5, PPWP Pro allows you to run our shortcode under Custom Post Types as well as Custom Fields
- Integrate with Prevent Direct Access Gold to protect files embedded in content
- Support both Gutenberg & Classic Editor
- Support multiple passwords per shortcode
- Two passwords are separated by at least one space
- Support multiple shortcodes per page
- Users just enter passwords one time to unlock all content protected by the same password
- Support cookies which allow users to access hidden sections in a period of time without re-entering password
- Set the cookies time’s value under setting page
We provide some attributes to customize the password form as well as protection type to suit each individual needs as below:
Any roles in whitelist won’t have to enter the password to access the hidden section. The available options include:
[ppwp passwords="password1 password2" whitelisted_roles="administrator, editor"] Your protected content [/ppwp]
- headline: Overwrite the default title of your password form.
- Default value: “Restricted Content”
- Accept HTML tags
[ppwp passwords="password1 password2" headline="custom headline"] Your protected content [/ppwp]
- description: Overwrite the default description of your password form.
- Default value: “To view this protected content, enter the password below:”
- Accept HTML tags
[ppwp passwords="password1 password2" description="custom description"] Your protected content [/ppwp]
- label: Overwrite the default password label of your password form.
- Default value: “Password:”
[ppwp passwords="password1 password2" label=""] Your protected content [/ppwp]
- placeholder: Add placeholder to your password form.
[ppwp passwords="password1 password2" placeholder="custom placeholder"] Your protected content [/ppwp]
- button: Overwrite the default button text of your password form.
- Default value: “Enter”
[ppwp passwords="password1 password2" button="custom button text"] Your protected content [/ppwp]
- error_msg: Overwrite the default message shown when users enter the wrong password.
- Default value: “Please enter the correct password!”
- Accept HTML tags
[ppwp passwords="password1 password2" error_msg="Please try again!"] Your protected content [/ppwp]
- id & class: Allow you to apply a style to your password form and match your custom theme.
[ppwp id="custom-id" class="custom-class" passwords="password1 password2"] Your protected content [/ppwp]
Known Issues and Solutions
In case your site disables footer, our partial content protection shortcode will not work.
There is a workaround to resolve this.
Go to Plugins > Plugin Editor. Select our Password Protect WordPress plugin.
Under line 81 of this file public/class-ppw-public.php:81, add these 2 lines
$shortcode = new PPW_Shortcode(); $shortcode->add_scripts();
Now password protect partial content function will work on your site as usual.