• Hello,

    i can’t add a redirect url to age gate when visitors select no.

    Could you help me fix this?

    Thanks

    Ricardo

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

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

    (@philsbury)

    Hi @ricardogrune,

    Are you trying to redirect to an external website or a page within your own site?

    Thanks
    Phil

    @philsbury
    Hi Phil – I want to redirect to an external website or to a page in my own site. I require both choices. Is there a simple way to set this up?

    Thanks for being so active here!

    Plugin Author Phil

    (@philsbury)

    Hi @sebastiansebastian,

    A couple of things I need to know here:
    When do you want to do the redirect (pass/fail/certain post to post_type etc)
    Are you using “standard” or JS mode?

    Thanks
    Phil

    Hi Phil,

    Thanks for getting back to me so fast. I want to redirect on pass. I’m using standard mode right now.

    Plugin Author Phil

    (@philsbury)

    Hi @sebastiansebastian,

    Then that’s definitely possible, you can use the age_gate_form_success hook, here’s an example where I redirect posts to one url and pages to another:

    
    add_action('age_gate_form_success', function($meta){ 
    
      $postId = url_to_postid( site_url($meta['age_gate_content'] ));
      $post_type = get_post_type($postId);
      
      switch ($post_type) {
        case 'page':
          header('Location: https://bbc.co.uk');
          exit;
          break;
        case 'post':
          header('Location: https://google.com');
          exit;
          break;
      }
      
    });
    

    Probably don’t actually need the breaks in there as it exits before it gets there…

    Thanks
    Phil

    Thank you again for all your help!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Can’t add a Redirect url’ is closed to new replies.