Title: Age Gate Bypass
Last modified: October 27, 2021

---

# Age Gate Bypass

 *  Resolved [johncmorris74](https://wordpress.org/support/users/johncmorris74/)
 * (@johncmorris74)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/age-gate-bypass/)
 * 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](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fage-gate-bypass%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

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

 *  Plugin Author [Phil](https://wordpress.org/support/users/philsbury/)
 * (@philsbury)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/age-gate-bypass/#post-15016635)
 * Hi [@johncmorris74](https://wordpress.org/support/users/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](https://wordpress.org/support/users/johncmorris74/)
 * (@johncmorris74)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/age-gate-bypass/#post-15016929)
 * 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](https://wordpress.org/support/users/philsbury/)
 * (@philsbury)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/age-gate-bypass/#post-15016950)
 * Hi [@johncmorris74](https://wordpress.org/support/users/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 4 years, 5 months ago by [Phil](https://wordpress.org/support/users/philsbury/).
 *  Thread Starter [johncmorris74](https://wordpress.org/support/users/johncmorris74/)
 * (@johncmorris74)
 * [4 years, 5 months ago](https://wordpress.org/support/topic/age-gate-bypass/#post-15016954)
 * 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.

 * ![](https://ps.w.org/age-gate/assets/icon-256x256.png?rev=2783003)
 * [Age Gate](https://wordpress.org/plugins/age-gate/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/age-gate/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/age-gate/)
 * [Active Topics](https://wordpress.org/support/plugin/age-gate/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/age-gate/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/age-gate/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [johncmorris74](https://wordpress.org/support/users/johncmorris74/)
 * Last activity: [4 years, 5 months ago](https://wordpress.org/support/topic/age-gate-bypass/#post-15016954)
 * Status: resolved