How to Password Protect Instapage Landing Page

Instapage plugin for WordPress allows you to seamlessly publish landing pages built via the Instapage platform.

That being said, Instapage doesn’t use WordPress built-in function to create a landing page. As a result, the page is not protected by the PPWP plugin by default.

To protect your entire site including the Instapage landing page, simply follow 2 simple steps below.

Requirements:

  1. Modify the Instapage plugin’s code as shown below
    $noReplace = apply_filters('instapage_no_replace', is_admin() || $this->isLoginPage() || InstapageCmsPluginHelper::isCustomParamPresent() );
  2. Add our custom code to your (child) theme’s functions.php file
add_filter('instapage_no_replace', function ($noReplace) {
	if ( ! class_exists( 'PPW_Pro_Settings_Services' ) ) {
		return $noReplace;
	}

	$is_protect = ppw_pro_get_setting_entire_site_type_bool( PPW_Constants::IS_PROTECT_ENTIRE_SITE );
	$is_protect = apply_filters( 'ppwp_sitewide_is_enabled', $is_protect );
	if ( ! $is_protect ) {
		return $noReplace;
	}

	$has_bypass = apply_filters( 'ppwp_sitewide_has_bypass', false );
	if ( $has_bypass ) {
		return $noReplace;
	}

	// Sitewide passwords of another plugin (PPWP Suite, etc...) can overwrite sitewide passwords of PPWP.
	$entire_site_passwords = apply_filters( 'ppwp_sitewide_passwords', false );
	if ( ! $entire_site_passwords ) {
		$entire_site_passwords = ppw_pro_get_setting_entire_site_type_array( PPW_Pro_Constants::PPW_PASSWORD_FOR_ENTIRE_SITE );
	}

	$passwords = ppw_pro_get_string_key_in_array( $entire_site_passwords );

	$settings_service    = new PPW_Pro_Settings_Services();

	do_action( 'ppwp_sitewide_handle_before_valid_password', $passwords, $entire_site_passwords, $settings_service );
	if ( $settings_service->has_permission_to_access_sitewide_content( $passwords ) ) {
		return $noReplace;
	}

	return true;
});
Lasted updated on May 5, 2021