Display different ‘Thank you’ page content depending on from used on the page

Is there a way of finding the URL of the WP page that the user is coming from using PHP?

For example if they are on - http://www.spa***.co.uk/plymouth/feedback - they complete a form and are then redirected to - http://www.spa***.co.uk/thanks

I want to pick up /plymouth/ and change a couple of things as the page thanks page is displayed.

I would like to be able to display a different ‘Thank you’ page content depending on from which page the user comes from.

  • Kasia Swiderska

    Hello Christopher,

    I consulted this with developer and because this form is Ajax form you can't use $_SERVER['REQUEST_URI'] . Instead you will need to modify your form and use hidden input field that will grab a current page url. Something like this:

    <input type="hidden" name="current-page" value="<?php echo get_permalink() ?>" />

    when you have field with value then you can process this field in your function the same like you do with other fields. Something similar to this

    $url = $data['current-page'];

    and then you can check if name of the city is in variable $url.
    Let me know if you have more questions.

    kind regards,

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.