Password Protected Shortcode

Below, you’ll find a detailed guide on how to add the Password Protected Shortcode to your WordPress website, including its parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the Password Protected Plugin shortcode not to show or not to work correctly.

Before starting, here is an overview of the Password Protected Plugin and the shortcodes it provides:

Plugin Icon
Password Protected

"Password Protected is a robust WordPress plugin that secures your site. It provides an additional password layer, ensuring only authorized users access specific areas of your website."

★★★★✩ (106) Active Installs: 400000+ Tested with: 6.3.2 PHP Version: 5.6
Included Shortcodes:
  • [password_protected_logout_link]

Password Protected [password_protected_logout_link] Shortcode

The ‘password_protected_logout_link’ shortcode is a feature in WordPress that enables users to log out from a specific page. . This shortcode allows customization such as redirecting users to a certain page after logging out, or changing the text displayed on the logout link.

Shortcode: [password_protected_logout_link]

Parameters

Here is a list of all possible password_protected_logout_link shortcode parameters and attributes:

  • redirect_to – URL where you will be redirected after logout
  • text – the content that will replace the shortcode in the post

Examples and Usage

Basic example – A simple use of the password protected logout link shortcode without any additional attributes.

[password_protected_logout_link]

Advanced examples

Using the shortcode to display a logout link with a custom redirect. After logout, users will be redirected to the specified URL.

[password_protected_logout_link redirect_to="http://example.com"]

Another advanced usage of the shortcode is to display a logout link with custom text. The specified text will be used as the logout link text.

[password_protected_logout_link text="Logout Now"]

In this example, the shortcode is used to display a logout link with both custom redirect and custom text. After logout, users will be redirected to the specified URL and the logout link will display the specified text.

[password_protected_logout_link redirect_to="http://example.com" text="Logout Now"]

PHP Function Code

In case you have difficulties debugging what causing issues with [password_protected_logout_link] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'password_protected_logout_link', array( $this, 'logout_link_shortcode' ) );

Shortcode PHP function:

function logout_link_shortcode( $atts, $content = null ) {

		$atts = shortcode_atts(
			array(
				'redirect_to' => '',
				'text'        => $content,
			),
			$atts,
			'logout_link_shortcode'
		);

		return $this->logout_link( $atts );

	}

Code file location:

password-protected/password-protected/password-protected.php

Conclusion

Now that you’ve learned how to embed the Password Protected Plugin shortcode, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.

Comments

Leave a Reply

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