Hi, thanks for using Force Login!
I’m afraid you’ll have to write your own logic to customize the plugin to meet your needs.
You should be able to bypass Force Login based on any condition.
Good luck!
All right,
I’m not a PHP programmer but I found this solution:
I have placed this piece of code into the v_forcelogin() function (at line 24):
// IP Address Whitelist
$ip = $_SERVER['REMOTE_ADDR']; // Get public IP
if ($ip == '1.2.3.4') return; // Repeat this line to exclude more IPs
Thank you for forcing me to learn something new 🙂
-
This reply was modified 5 years, 2 months ago by Combinatix.
Hi, I’m glad you got it working!
However, editing plugin files is not best practice. If you update the plugin, all of your custom changes will be lost.
It’s better to apply custom changes through hooks and filters via your theme’s functions.php file or a custom plugin of your own.
For example, add your custom code like this:
/**
* Bypass Force Login to allow for exceptions.
*
* @param bool $bypass Whether to disable Force Login. Default false.
* @return bool
*/
function my_forcelogin_bypass( $bypass ) {
$ip = $_SERVER['REMOTE_ADDR']; // Get public IP
if ( '1.2.3.4' == $ip ) {
$bypass = true;
}
return $bypass;
}
add_filter( 'v_forcelogin_bypass', 'my_forcelogin_bypass' );