0

I'm searching for a way to mask a wordpress page url or create a one time url. I have a webshop which redirects to a signup form after sucessful payment but I don't want anyone to use the link more than once.

I found a solution here from cabrerahector with a javascript which I partly got working. WordPress: Mask page URL I could get it to redirect to the startpage, only problem was it does all the time even if id is correct. Any suggestions?

   function mycustom_wp_head() {
$home_url = get_home_url();
$contact_page_ID = 22; // Change this to your "Contact" page ID
$thank_you_page_ID = 2; // Change this to your "Thank You" page ID

if ( is_page($thank_you_page_ID) ) :
?>
<script>
    var allowed_referer_url = '<?php echo get_permalink( $contact_page_ID ); ?>';

    // No referer, or referer isn't our Contact page,
    // redirect to homepage
    if ( ! document.referrer || allowed_referer_url != document.referrer ) {
        window.location = '<?php echo $home_url; ?>';
    }
</script>
<?php
    endif;
}

    add_action( 'wp_head', 'mycustom_wp_head' );
  • Have you checked [this post](https://wordpress.stackexchange.com/a/212322) out? You might have more help on [wordpress.stackexchange.com](https://wordpress.stackexchange.com/) instead of SO. – technogeek1995 Sep 13 '19 at 16:30
  • How are you redirecting the user to the signup form? (Share the code you're using for that.) – cabrerahector Sep 13 '19 at 16:35
  • They are redirected from the checkout page after payment is made throught the custom thank you page plugin. I don't know how thats done. It works if I make a link at the thankyou page which you press. But then you will se that url and can share it – Andreas Damberg Sep 14 '19 at 09:58

0 Answers0