• Is there a way to disable age gate if coming from a specified url, ie:

    If coming from https://www.website.com (or any url with website.com in it ie website.com/about or website.com/contact etc) to https://www.subdomain.website.com age gate doesnt show.

    there is already a age gate on ‘website.com’ so going to ‘subdomain.website.com’ will mean a user would have to go through age gate twice.

    • This topic was modified 2 years, 5 months ago by fme101.

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

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

    (@philsbury)

    Hi @fme101,

    If you’re on a multisite it should do this already. But if it’s two separate WordPress installs both with Age Gate then it you update to the latest version (2.21.0) of age gate you can do the following to share the cookie across subdomains:

    
    add_filter('age_gate/cookie_domain', function ($domain) {
        return '.' . get_domain($_SERVER['SERVER_NAME']);
    });
    
    // modified from: https://www.beliefmedia.com.au/root-domain-url-php
    function get_domain($url, $tld = false)
    {
        $scheme = parse_url($url, PHP_URL_SCHEME);
        if (empty($scheme)) {
            $url = 'https://' . ltrim($url, '/');
        }
    
        $pieces = parse_url($url);
        $domain = isset($pieces['host']) ? $pieces['host'] : '';
        if (preg_match('/(?P<domain>[a-z0-9][a-z0-9\-]{1,63}\.[a-z\.]{2,6})$/i', $domain, $m)) {
            return ($tld === true) ? substr($m['domain'], ($pos = strpos($m['domain'], '.')) !== false ? $pos + 1 : 0) : $m['domain'];
        }
        return false;
    }
    

    Thanks
    Phil

    Thread Starter fme101

    (@fme101)

    thanks Phil – where do i add the code?

    Plugin Author Phil

    (@philsbury)

    Hi @fme101,

    It can go functions.php

    Thanks
    Phil

    Thread Starter fme101

    (@fme101)

    Hi Phil – that doesnt seem to have worked,

    Do you offer a support service to have a look at it and see if you can get it to work?

    Plugin Author Phil

    (@philsbury)

    Hi @fme101,

    if you have a link to the two sites I can see if I can work something out

    Thanks
    Phil

    Thread Starter fme101

    (@fme101)

    if age gate completed on [ link moved to link field ]

    then disable age gate on this site https://members.mydomain-in-link-field

    • This reply was modified 2 years, 4 months ago by Jan Dembowski.
    Plugin Author Phil

    (@philsbury)

    Hi @fme101,

    The second site has coming soon so obviously can’t check that one, but the main site has the cookie domain without the . at the start. Did you add the above code to both sites?

    Thanks
    Phil

    Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    Side note: @fme101 For sites that are Not Safe For Work, and this plugin gets those for obvious reasons, please mark it so and use the link field.

    I’ve done that for you.

    Thread Starter fme101

    (@fme101)

    Hi Phil,

    Ive since disabled the coming soon – i think age gate (for disabling if coming from a certain website) worked on version 2x but seems to have stopped working

    When user completes age gate on https://sventertainment.net/agt/
    and clicks on ‘Member link here’ on this page (and any other link), they are redirected to
    https://members.sventertainment.net where age gate is disabled.

    Dont think i need it vice/versa

    Thread Starter fme101

    (@fme101)

    I get this message

    “Misdirected Request

    The client needs a new connection for this request as the requested host name does not match the Server Name Indication (SNI) in use for this connection.”

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘[NSFW] Disable if coming from a specific website’ is closed to new replies.