Resolving Common PHP Errors and Conflicts with the Password Protected Plugin
Content
Users of the 'Password Protected – Password Protect your WordPress Site, Pages, & WooCommerce Products – Restrict Content, Protect WooCommerce Category and more' plugin occasionally encounter PHP errors or conflicts with other software. This guide covers the most common issues and their solutions, compiled from community reports.
Common PHP Notices and Deprecation Warnings
PHP notices are often related to outdated code or missing server variables. They don't always break a site but can fill error logs.
- Undefined index: REMOTE_ADDR: This occurs when a script like
wp-cron.phpis called from the command line, where theREMOTE_ADDRserver variable is not set. The plugin's code should check if the variable exists before using it. This was reportedly fixed in version 2.2.4. - Undefined index: redirect_to: A notice can appear if the
$_REQUEST['redirect_to']variable is not set before it's used in the login template file. A code check should be added to ensure the variable exists. - Trying to get property of non-object: An error on a line like
$postID = $post->ID;suggests the global$postobject is not available in that context. The code should be modified to check if$postis an object before trying to access its properties. - Deprecated Function Warnings: Newer PHP and WordPress versions deprecate old functions.
- wp_no_robots: WordPress 5.7 deprecated
wp_no_robots(). It should be replaced with a function that adds thewp_robots_no_robotsfilter. A working solution is:function cc_no_robots(){ add_filter( 'wp_robots', 'wp_robots_no_robots' ); } add_action( 'password_protected_login_head', 'cc_no_robots' ); - PHP 8.3 Deprecations: Calls to
get_class()without arguments are deprecated. The code must be updated to pass an object to the function. - Nullable Parameter Deprecations: Warnings about implicitly nullable parameters in the Freemius SDK require updating the SDK files manually or waiting for a plugin update that includes the patched version.
- wp_no_robots: WordPress 5.7 deprecated
Plugin Conflicts
The plugin can sometimes conflict with other popular WordPress plugins.
- Contact Form 7: A known conflict can prevent CF7 forms from submitting, often accompanied by a
TypeError: data is nullconsole error. This conflict can occur even when password protection is turned off. The only current solution is to deactivate one of the plugins until a permanent fix is released. - W3 Total Cache: Caching can interfere with the login cookie. To resolve this, navigate to W3 Total Cache's Page Caching settings and add
bid_1_password_protected_authto the list of rejected cookies. - Elementor/REST API: Version 2.6.7 of the plugin introduced a bug that blocked REST API access, breaking the block editor and page builders. This was a significant issue that required a subsequent update to fix. If experiencing problems with editors or Elementor, ensure the plugin is updated to the latest version and that "Allow REST API Access" is enabled in its settings.
Other Common Issues
- Parse Error on Activation: A syntax error preventing activation is almost always caused by an outdated PHP version on the server. The plugin requires a minimum of PHP 7.4. Users should contact their hosting provider to upgrade their PHP version.
- "Allow Users" Not Working: An old bug report indicated the "Allow Users" feature was not functioning correctly due to a missing
is_user_logged_in()check in the code. This has likely been addressed in more recent versions of the plugin.
Security Vulnerabilities
The plugin has had documented security vulnerabilities, such as a Reflected Cross-Site Scripting (XSS) vulnerability. It is critical to always keep the plugin updated to the latest version to ensure any patched vulnerabilities are applied to your site. Users should subscribe to security bulletins to be notified of updates.
General Troubleshooting Steps
- Update Everything: First, ensure WordPress, the Password Protected plugin, your theme, and all other plugins are updated to their latest versions.
- Check PHP Version: Confirm your server is running at least PHP 7.4. This resolves many activation and deprecation errors.
- Conflict Test: If you encounter strange behavior, deactivate all other plugins and switch to a default theme (like Twenty Twenty-Four). If the issue resolves, reactivate your plugins one by one to identify the conflict.
- Review Settings: For issues with accessing the admin area or REST API, enable the "Allow Administrators" and "Allow REST API Access" options within the Password Protected settings.
Related Support Threads Support
-
wp_no_robots deprecatedhttps://wordpress.org/support/topic/wp_no_robots-deprecated/
-
Do you have a package published somewhere for composer install?https://wordpress.org/support/topic/do-you-have-a-package-published-somewhere-for-composer-install/
-
PHP Notice Trying to get property of non-objecthttps://wordpress.org/support/topic/php-notice-trying-to-get-property-of-non-object-16/
-
Compatible with 5.8?https://wordpress.org/support/topic/compatible-with-5-8/
-
Allow Usershttps://wordpress.org/support/topic/allow-users/
-
PHP Notice: Undefined index: REMOTE_ADDRhttps://wordpress.org/support/topic/php-notice-undefined-index-remote_addr-2/
-
conflict with elementorhttps://wordpress.org/support/topic/conflict-with-elementor-20/
-
PHP versionhttps://wordpress.org/support/topic/php-version-68/
-
Admin heading structure is incorrecthttps://wordpress.org/support/topic/admin-heading-structure-is-incorrect-42/
-
Is PPWP plugin compatible with Page Builders?https://wordpress.org/support/topic/is-ppwp-plugin-compatible-with-page-builders/
-
New 2.6 Update Parse/syntax/unexpected errorhttps://wordpress.org/support/topic/new-2-6-update-parse-syntax-unexpected-error/
-
Plugin Vulnerability Reported by WP Engine: Is this patched?https://wordpress.org/support/topic/plugin-vulnerability-reported-by-wp-engine-is-this-patched/
-
Possible Undefined index: redirect_tohttps://wordpress.org/support/topic/possible-undefined-index-redirect_to/
-
Author Name and URL Changedhttps://wordpress.org/support/topic/author-name-and-url-changed/
-
W3 Total Cache compatibilityhttps://wordpress.org/support/topic/w3-total-cache-compatibility-6/
-
WP 5.7 Defreciated Functionhttps://wordpress.org/support/topic/wp-5-7-defreciated-function/
-
Cannot activate themehttps://wordpress.org/support/topic/cannot-activate-theme-2/
-
php 8.3 deprecated codeshttps://wordpress.org/support/topic/php-8-3-deprecated-codes/
-
Version 2.6.7 breaks REST APIhttps://wordpress.org/support/topic/version-2-6-7-breaks-rest-api/
-
Plugin Supported?https://wordpress.org/support/topic/plugin-supported-2/
-
deprecated notice on class constructorhttps://wordpress.org/support/topic/deprecated-notice-on-class-constructor/
-
Some ERRORShttps://wordpress.org/support/topic/some-errors-32/
-
Support for WordPress 5.3?https://wordpress.org/support/topic/support-for-wordpress-5-3-2/
-
Want to use plugin paid versionhttps://wordpress.org/support/topic/want-to-use-plugin-paid-version/
-
PHP 8.2. suppport pleasehttps://wordpress.org/support/topic/php-8-2-suppport-please/
-
Using transients no long working since 2.7.x updatehttps://wordpress.org/support/topic/using-transients-no-long-working-since-2-7-x-update/
-
Author Name & URL Changedhttps://wordpress.org/support/topic/author-name-url-changed/
-
Plugin – Child Theme Conflict – Editor not usablehttps://wordpress.org/support/topic/plugin-child-theme-conflict-editor-not-usable/
-
my client received email from wordpress at domain dot euhttps://wordpress.org/support/topic/my-client-received-email-from-wordpress-at-domain-dot-eu/
-
408 Request Time-Outhttps://wordpress.org/support/topic/408-request-time-out-2/
-
Causing major conflict with Contact Form 7https://wordpress.org/support/topic/causing-major-conflict-with-contact-form-7/
-
please fix reflected cross site scripting xss vulnerabilityhttps://wordpress.org/support/topic/please-fix-reflected-cross-site-scripting-xss-vulnerability/
-
Bug, invalid path in freemius causes PHP Warningshttps://wordpress.org/support/topic/bug-invalid-path-in-freemius-causes-php-warnings/
-
Plugin conflicthttps://wordpress.org/support/topic/plugin-conflict-197/
-
Creation of dynamic property Password_Protected::$admin_cachinghttps://wordpress.org/support/topic/creation-of-dynamic-property-password_protectedadmin_caching/
-
Fatal error when activating pluginhttps://wordpress.org/support/topic/fatal-error-when-activating-plugin-49/
-
Plugin still active?https://wordpress.org/support/topic/plugin-still-active-3/
-
Plugin no longer workinghttps://wordpress.org/support/topic/plugin-no-longer-working-42/