• Mikko

    (@sainionmikko)


    Hi,

    I’ve scanned the documentation and this support forum, but don’t seem to be able to find a way to exclude content at html element level if the age gate was not passed. In the PHP rendering the page, I would like to echo some element only if the age gate was passed and show all other content in any case. I can read the cookie, and if that’s set, the gate would be passed. I would have to reload the page however after passing the gate for the cookie to be set and read before rendering the page. Is there a way to do that? Or perhaps I’m looking for a PHP function that would tell me if the gate was passed. Or is the plugin writing any classes to some elements of tha passed page? That might work too. I found there might be a javascript event that fires when the gate is passed, but no documentation on that. With that, I could write my own classes.

Viewing 1 replies (of 1 total)
  • Thread Starter Mikko

    (@sainionmikko)

    Actually, I worked out the following method:

    1. Refresh page when Age Gate is passed using the JavaScript event:
      window.addEventListener(‘age_gate_passed’, function() {? ? location.reload();
      })
    2. Checking if cookie is set in my PHP template; after the refresh it is correctly set:
      $age_passed = isset($_COOKIE[‘age_gate’]);

    $age_passed is my boolean variable to use on elements to render only when the Age Gate was passed. Does this sound like it would work?

Viewing 1 replies (of 1 total)
  • The topic ‘Function and hook reference?’ is closed to new replies.