Smart Passworded Pages Shortcode

Below, you’ll find a detailed guide on how to add the Smart Passworded Pages 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 Smart Passworded Pages Plugin shortcode not to show or not to work correctly.

Before starting, here is an overview of the Smart Passworded Pages Plugin and the shortcodes it provides:

Plugin Icon
Smart Passworded Pages

"Smart Passworded Pages is a WordPress plugin that enhances your site's security. It allows you to add password protection to specific pages, ensuring only authorized users access your content."

★★★★☆ (21) Active Installs: 4000+ Tested with: 4.2.36 PHP Version: false
Included Shortcodes:
  • [smartpwpages]

Smart Passworded Pages [smartpwpages] Shortcode

The SmartPWPages shortcode is designed to create a password-protected form on a page. It uses the ‘smartpwpages’ shortcode to generate a form with an input field for password entry. The form displays an error message if an incorrect password is entered. It also includes hidden fields for additional security measures. The shortcode allows customization of the submit button label.

Shortcode: [smartpwpages]


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

  • label – Text displayed on the submit button
  • ID – Unique identifier for the form
  • parent – ID of the parent post or page

Examples and Usage

Basic example – A simple usage of the smartpwpages shortcode with default parameters.

[smartpwpages /]

Advanced examples

1. Specifying the ‘label’ attribute – Changes the default ‘Enter’ button label to ‘Submit’.

[smartpwpages label="Submit" /]

2. Specifying the ‘ID’ attribute – Changes the default form ID from ‘smartPWLogin’ to ‘customID’.

[smartpwpages ID="customID" /]

3. Specifying the ‘parent’ attribute – Changes the default parent post ID to a specific one, let’s say ‘123’.

[smartpwpages parent="123" /]

4. Using multiple parameters – This example combines the ‘label’, ‘ID’, and ‘parent’ attributes.

[smartpwpages label="Submit" ID="customID" parent="123" /]

PHP Function Code

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

Shortcode line:

add_shortcode( 'smartpwpages', array( $smartPWPages, 'smartpwpages_shortcode' ) );

Shortcode PHP function:

function smartpwpages_shortcode( $atts ) {
		global $post;

		extract( shortcode_atts( array(
			'label' => __( 'Enter', 'smartpwpages' ),
			'ID' => 'smartPWLogin',
			'parent' => $post->ID,
		), $atts ) );

		$result =  '<form ID="' . esc_attr( $ID ) . '" method="post" action="' . esc_url( get_permalink() ) . '" >' . PHP_EOL;
		if ( isset( $_GET['wrongpw'] ) ) $result .= '<p id="smartPWError">' . __( 'You\'ve entered an invalid password.</p>', 'smartpwpages' ) . PHP_EOL;
		$result .= '	<input class="requiredField" type="password" name="smartPassword" id="smartPassword" value=""/>' . PHP_EOL;
		$result .= '	<input type="hidden" name="smartParent" value="' .  (int) $parent . '" />' . PHP_EOL;
		$result .= '	<input type="hidden" name="smartPWPage_nonce" value="' . wp_create_nonce( 'smartPWPage' ).'" />' . PHP_EOL;
		$result .= '	<input type="submit" value="' . esc_attr( $label ). '" />' . PHP_EOL;
		$result .= '</form>' . PHP_EOL;
		return $result;

Code file location:



Now that you’ve learned how to embed the Smart Passworded Pages 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.


Leave a Reply

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