PPWP Pro Hooks, REST APIs, & Public Functions

Since version 1.3, Password Protect WordPress Pro provides RESTful APIs and public functions to achieve the following:

PPWP public action & filter hook

CategoryHookTypeAvailable on
Individual Protection
ppwp_qal_single_allowed_pagefilterPro
ppwp_single_page_robots_contentfilterPro
Partial Protection
ppwp_qal_pcp_allowed_pagefilterPro
Sitewide Protection
ppw_custom_header_form_entire_siteactionFree
ppw_custom_footer_form_entire_siteactionFree
ppwp_sitewide_headactionPro
ppwp_sitewide_footeractionPro
ppwp_before_show_sidewide_formactionPro
ppwp_sitewide_error_messagefilterPro
ppwp_sidewide_robots_contentfilterPro

Where are sitewide passwords stored?

PPWP Free and Pro store sitewide passwords under wp_options table:

  • PPWP Free’s option name is wp_protect_password_set_password_options
  • PPWP Pro’s option name is ppw_entire_site_options

With PPWP Suite extension, we migrate sitewide passwords to our own wp_pda_passwords table for extended features management.

Change Shortcode Passwords Conditionally

Use the following hook to filter passwords shortcode attribute when protecting partial content.

add_filter( 'ppw_shortcode_passwords', 'ppw_filter_shortcode_passwords' );
/**
 * Filter PPWP Passwords.
 * 
 * @param array $passwords Array shortcode passwords.
 * 
 * @return array
 */
function ppw_filter_shortcode_passwords( $passwords ) {
	// Filter array passwords.
	return $passwords;
}

Hide “Password Protection” column

There are 3 ways to hide our “Password Protection” column in the Pages or Posts dashboard.

Option 1: Untick that column in the Screen Options.

Option 2: Use the Admin Columns plugin.

Option 3: Add the following custom codes to your (child) theme’s functions.php file.

For PPWP Free version

$post_types = array( 
			'posts', 
			'pages', ); 
		foreach ( $post_types as $post_type ) { 
			add_filter( "manage_${post_type}_posts_columns", function ( $columns ) { 
				unset( $columns['ppw_password_protection'] ); 
				return $columns; }, 99 ); }

For PPWP Pro version

$post_types = array( 
			'posts', 
			'pages', 
			'your-custom-post-type' ); 
		foreach ( $post_types as $post_type ) { 
			add_filter( "manage_${post_type}_columns", function ( $columns ) { 
				unset( $columns['pda_password_protection'] ); 
				return $columns; }, 99 ); }

Remove ?ppwp=1 query string

Once users enter the right password, our plugin will add ?ppwp=1 query string to the page URL for tracking purposes. This doesn’t affect your site whatsoever.

However, if you want to remove the query string for some reason, simply add the following codes to your (child) theme’s functions.php file.

add_filter('ppwp_ppf_redirect_url_before_return_content', function ($url) {
    $url = add_query_arg('ppwp', null);
    return $url;
});

Use multiple QAL parameters

Each type of our quick access links comes with a different access token and you can’t use them all at the same time.

If you want users to be able access multiple protection layers at once, simply add the following code snippet to your (child) theme’s functions.php file.

add_filter( 'ppwp_shortcode_url', function ( $url ) {
	if ( ! class_exists( 'PPW_Pro_Constants' ) ) {
		return $url;
	}

	$bypass_key = PPW_Pro_Constants::BYPASS_PARAM;
	if ( ! isset( $_GET[ $bypass_key ] ) ) {
		return $url;
	}

	// Do not truncate the ppwp_ac params.
	$query = wp_parse_url( $url, PHP_URL_QUERY );

	$by_pass_val  = $_GET[ PPW_Pro_Constants::BYPASS_PARAM ];
	$bypass_param = "$bypass_key=$by_pass_val";
	if ( $query ) {
		$url .= "&$bypass_param";
	} else {
		$url .= "?$bypass_param";
	}

	return $url;
} );
Lasted updated on March 23, 2021