• Resolved woomigrating

    (@woomigrating)


    First, thanks a lot for the free plugin, works perfect!

    I would just like to add IP’s to omit from the pop-up manually, where would I add them if possible?

    Also I’d like to delay the pop-up x seconds, could you tell me where to add this?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Phil

    (@philsbury)

    Hi @woomigrating,

    Sorry for the slow reply.

    Both things are possible, but to delay showing the popup you would have to be using the JavaScript version.

    When certain filters are applied, the JS version will do those before showing the age gate, so it’s possible to do both the things in one. You can add this to your functions.php or a custom plugin:

    
    /**
     * IP Whitelisting
     */
    add_filter('age_gate_restricted', 'age_ip_whitelist');
    
    function age_ip_whitelist($restricted){
    
      // add whaterver IP addresses here
      $ips = array('192.168.x.x', '1.1.1.1');
    
      if(in_array($_SERVER['REMOTE_ADDR'], $ips)){
        // it's in the whitelist, so return false
        return false;
    
      } else {
        // Not whitelisted so wait, then return the original restriction.
        // Keep in mind there will already be a bit of a delay as this is an ajax call
        sleep(5); // wait 5 seconds before returning
        return $restricted;
    
      }
    }
    

    Hope that helps.

    Thanks
    Phil

    Thread Starter woomigrating

    (@woomigrating)

    Thank you, this worked until your last plugin update. Now the pop-up keep popping up with each page load (after the 5s sleep).
    When disabling this filter the pop-up behaves normal and pop-up only once per visitor/session.

    Could you make a updated version of this filter which works with your latest version of the plugin?

    Plugin Author Phil

    (@philsbury)

    Hi @woomigrating,

    That’s interesting, nothing in the update should have affected this, but let me look into it and come back to you.

    Thanks
    Phil

    Plugin Author Phil

    (@philsbury)

    Hi again @woomigrating,

    Not sure what’s happened there, or why it actually worked before, but this should sort it out

    
    /**
     * IP Whitelisting
     */
    add_filter('age_gate_restricted', 'age_ip_whitelist', 10, 2);
    
    function age_ip_whitelist($restricted, $meta){
      // modify $restriction
      $restricted = (isset($_COOKIE['age_gate']) && $_COOKIE['age_gate'] >= $meta->age) ? false : $restricted;
    
      // add whaterver IP addresses here
      $ips = array('192.168.x.x', '1.1.1.1');
    
      if(in_array($_SERVER['REMOTE_ADDR'], $ips)){
        // it's in the whitelist, so return false
        return false;
    
      } else {
        // Not whitelisted so wait, then return the modified restriction.
        // Keep in mind there will already be a bit of a delay as this is an ajax call
        sleep(5); // wait 5 seconds before returning
        return $restricted;
    
      }
    }
    

    This assumes that you’re not using the ‘anonymous’ setting, ‘ignore logged in’.

    Thanks
    Phil

    Thread Starter woomigrating

    (@woomigrating)

    Hawing multiple staging environments, testing different solutions, might have gotten me mixing it all up. Your filter very possibly didn’t work before either, but now it indeed does work!

    Thanks 🙂

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Add IP’s to omit / Delay pop-up’ is closed to new replies.