• Resolved Combinatix

    (@combinatix)


    Can you please help me creating excepion rule for whitelisting a bunch of IP addresses? IPv4 and IPv6 if possible.

    I need to allow access from our warehouse without password, but require password everywhere else.

    • This topic was modified 5 years, 2 months ago by Combinatix.
    • This topic was modified 5 years, 2 months ago by Combinatix. Reason: Title adjusting
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Kevin Vess

    (@kevinvess)

    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!

    Thread Starter Combinatix

    (@combinatix)

    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.
    Plugin Author Kevin Vess

    (@kevinvess)

    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' );
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Whitelist IP Address’ is closed to new replies.