It’s me again,
with a solution for the feature request “autologin with specific referer host name(s)”.
Now it is possible to autologin into the blog frontend, if the user is comming from a specific website.
I extended the function doHeadActions() in file wp-content/plugins/password-protect-wordpress/pluginCallbacks.php after this lines of code:
function doHeadActions()
{
$isEnabled = $this->_settings()->fetchSetting( "enabled" )->getValue();
if( $isEnabled == "off" ) {
//protection is disabled
return;
}
with my new code:
// autologin by referer host
$referer = @$_SERVER['HTTP_REFERER'];
$checkRefererHosts = array('www.source.net');
if (isset($referer)) {
$aParsedUrl = parse_url($referer);
if (isset($aParsedUrl['host'])) {
$refererHost = $aParsedUrl['host'];
if (in_array($refererHost, $checkRefererHosts)) {
//refresh logged in cookies
$this->setCookie();
return;
}
else {
$isLoggedIn = apply_filters( $this->_slug( "isLoggedIn" ), false );
if (false === $isLoggedIn ) {
do_action( $this->_slug( "displayLoginPage" ) );
exit;
}
}
}
It works fine, but It’s not update safe.
Couldn’t it be a new feature in further releases of the plugin?
The referer hosts (checkRefererHosts) should be defined in settings of the plugin.
Greets TJ