• Resolved johncmorris74

    (@johncmorris74)


    My clients are wanting to bypass the age gate on their site when a certain link is clicked, for example, one being used for Facebook ads they are running by their marketing team. The marketing team says that they used HTTP GET parameters to bypass age gates on other sites. Would this be done by injecting PHP into the site via “My custom functions” plugin possibly? Do you have any insight on the best way to do this?

    The page I need help with: [log in to see the link]

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

    (@philsbury)

    Hi @johncmorris74,

    As you’re using the JS version, there’s a couple of steps but it’s possible.

    First, go to the Age Gate advanced settings and enable the “JS Hooks” option.

    You can then access some filters in javascript, but you can make it happen in PHP:

    add_action('wp_footer', function () {
        ?>
        <script>
            ageGateHooks.addFilter('age_gate_restricted', 'namespace', function(show){
            var params = new URLSearchParams(window.location.search);
            if (params.has('bypass')) {
                return false;
            }
            return show;
            });
        </script>
        <?php
    }, 1);

    just change the bypass parameter to be whatever you want it to be.

    Cheers
    Phil

    Thread Starter johncmorris74

    (@johncmorris74)

    Hey Phil,

    Thanks for that bit of code it did the trick! But when I navigate to another page the age gate shows. They want the cookie remembered so age gate won’t show on any pages. What could I add to get that to happen?

    Plugin Author Phil

    (@philsbury)

    Hi @johncmorris74,

    Adding document.cookie = "age_gate=" + 21 + "" + "; path=/"; in the if statement should do it. Full snippet:

    add_action('wp_footer', function () {
        ?>
        <script>
    
            ageGateHooks.addFilter('age_gate_restricted', 'namespace', function(show){
            var params = new URLSearchParams(window.location.search);
            if (params.has('bypass')) {
                document.cookie = "age_gate=" + 21 + "" + "; path=/";
                return false;
            }
            return show;
            });
        </script>
        <?php
    }, 1);

    Thanks
    Phil

    • This reply was modified 3 years, 4 months ago by Phil.
    Thread Starter johncmorris74

    (@johncmorris74)

    That indeed did the trick! Thanks a TON Phil! Have a great evening!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Age Gate Bypass’ is closed to new replies.