Shortcodes

Below is the list of all the shortcodes available on the Password Protect WordPress (PPWP) plugin and its extensions.

Password Protect WordPress (PPWP)

Protect part of the content

The [ppwp] shortcode enables you to protect a part of the content.

Example Shortcode

[ppwp id="" class="" passwords="password1 password2" whitelisted_roles="administrator, editor"]
Your protected content
[/ppwp]

Attributes

Below are all attributes available with this shortcode. It’s important to note that the shortcode is valid as long as it includes at least one of the (required*) attributes.

  • passwords (required*): Global inline passwords, which are used to unlock the protected section.
    • Each password is case-sensitivity and no more than 100 characters, but doesn’t contain [, ], “, ‘ and space characters.
    • Multiple passwords are separated by space.
  • pwd (required*): ID-based shortcode global passwords.
    • This attribute is available in PPWP Pro only.
    • Multiple IDs are separated by commas.
  • pwd_label (required*): Label-based shortcode global passwords.
    • This attribute is available in PPWP Pro only.
    • Multiple labels are separated by commas.
  • whitelisted_roles: Define who can access protected sections directly without entering a password.

Check out other attributes to customize the password form.

Create a sitewide login form

The [ppwp_sitewide] shortcode allows you to display the sitewide password form in any location on your site.

Example Shortcode

[ppwp_sitewide]

Log out password protected posts

The [ppwp_logout] shortcode displays a logout button allowing users to clear password cookies storing in their browsers.

Example Shortcode

[ppwp_logout type="single" post_ids="1, 2, 3"]

Attributes

The following attributes are shown within the sample shortcode above.

  • type: Define which password protected content type whose cookies will be removed. The available values include:
    • single: refers to cookies of individual protected content (default)
    • master: refers to cookies of master passwords
    • sitewide: refers to cookies of sitewide protection
    • pcp: refers to cookies of partial content protection
    • al: refers to cookies of level-based protection
    • group: refers to cookies of level-based protection

Multiple types are separated by commas.

  • post_ids: Define which password protected post whose cookies will be removed.
    • You can get the ID number by hovering over the desired post title.
    • It’s valid only if the type is “single” or “pcp”. Without this attribute, our plugin will clear cookies of all posts belonging to the defined type.
  • label: Define the label of the logout button. The default value is “Log Out”.
  • id & class: Allow you to apply a style to your logout button and match your custom theme.

PPWP Password Suite

Create a central login form

The [ppwp_central] shortcode allows you to create a central password form that will auto-redirect users to specific content after the right password is inputted.

Example Shortcode

[ppwp_central post_ids="1, 2, 3"]

Attributes

The following attributes are shown within the sample shortcode above.

  • post_ids (required)

The ID list of the protected content. You can get the ID number by hovering over the desired post title.

Reset expired passwords

The [ppwp_reset] shortcode allows your users to reset their expired passwords in the frontend of your site.

Example Shortcode 

[ppwp_reset type="single" post_ids="1, 2, 3"]

or

[ppwp_reset type="sitewide"]

Attributes

The following attributes are shown within the sample shortcode above.

  • type (required): The types of content that you want to reset the password.
    • Singe: reset passwords of individual pages
    • Sitewide: reset the sitewide passwords
  • post_ids: The ID list of the protected content.
    • You can get the ID number by hovering over the desired post title.
    • The attribute is valid as long as the type is single. Without this attribute, our plugin will reset expired passwords of all single content protected by PPWP plugin.

How to use shortcode

Shortcodes can be used anywhere within WordPress, including pages, posts, and sidebar widgets. Simply modify the example shortcode as your desired and paste it into the content editor.

Classic Editor

Gutenberg Editor

After saving the changes, you can see the item that shortcode intends to display from the frontend.

How to get post ID

Find the id of a post by simply hovering over its title. A link containing the post id will be shown at the bottom of the screen. In the example below, you can see the post ID is 1.

Lasted updated on July 8, 2020