# Is it possible to redirect to a page after submitting the smart form?

**URL:** <https://forum.pinegrow.com/t/is-it-possible-to-redirect-to-a-page-after-submitting-the-smart-form/4551>\
**Category:** Pinegrow WP\
**Created:** [September 23, 2020, 9:11pm UTC](https://forum.pinegrow.com/t/is-it-possible-to-redirect-to-a-page-after-submitting-the-smart-form/4551 "2020-09-23T21:11:05Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![beatngu](https://avatars.discourse-cdn.com/v4/letter/b/6a8cbe/32.png) [@beatngu](https://forum.pinegrow.com/u/beatngu)\
**Post date:** [September 23, 2020, 9:11pm UTC](https://forum.pinegrow.com/t/is-it-possible-to-redirect-to-a-page-after-submitting-the-smart-form/4551/1 "2020-09-23T21:11:05Z")

</div>

I am using the smart form and i want to redirect to a page after the form is submitted.  
Now it redirects to the same page and it would be nice to redirect to a custom “thank you page”.  
Is something like this possible when using the wp smart form?

---

<div class="post-metadata">

**Author:** ![snowfeald](https://avatars.discourse-cdn.com/v4/letter/s/57b2e6/32.png) [@snowfeald](https://forum.pinegrow.com/u/snowfeald)\
**Post date:** [November 26, 2020, 11:20am UTC](https://forum.pinegrow.com/t/is-it-possible-to-redirect-to-a-page-after-submitting-the-smart-form/4551/2 "2020-11-26T11:20:02Z")

</div>

Bump, I would love to know this as well

---

<div class="post-metadata">

**Author:** ![RobM](https://avatars.discourse-cdn.com/v4/letter/r/278dde/32.png) [@RobM](https://forum.pinegrow.com/u/RobM)\
**Post date:** [November 26, 2020, 3:47pm UTC](https://forum.pinegrow.com/t/is-it-possible-to-redirect-to-a-page-after-submitting-the-smart-form/4551/3 "2020-11-26T15:47:01Z")

</div>

@beatngu (sorry for the delay) and @snowfeald,  
It isn’t included as a smart form option, but you can add an If Option and PHP code from the WP Actions. I’m not sure if this is a sanctioned way to do this, as opposed to using wp\_safe\_redirect() or some other built-in WP function, but here is what I did.

1. Directly after your smart form add a div with inline styling of “display: none;” Note - you can also do this by adding in a php block and typing by hand
2. Add an If Option from the WP Actions
3. For condition add `$mailer->processed`
4. Add a PHP Code block from the WP Actions
5. For function add `echo '<script>window.location.href="redirect.to.here"</script>` and replace the element

This will create the following output in your theme file:

```auto
<?php if ( $mailer->processed ) : ?>
       <?php echo '<script>window.location.href="https://google.com/"</script>' ?>
 <?php endif; ?>

```

Again, not sure if this is the “safe” way to do it. No url sanitization or checks, but…  
Cheers,  
Bob

---

<div class="post-metadata">

**Author:** ![snowfeald](https://avatars.discourse-cdn.com/v4/letter/s/57b2e6/32.png) [@snowfeald](https://forum.pinegrow.com/u/snowfeald)\
**Post date:** [November 27, 2020, 9:26am UTC](https://forum.pinegrow.com/t/is-it-possible-to-redirect-to-a-page-after-submitting-the-smart-form/4551/4 "2020-11-27T09:26:17Z")

</div>

Hi Rob, following the initial steps where you place the IF and php code block on an invisibile div didn’t work (returned a php error so perhaps I was doing it wrong); so I simply pasted your theme output code below the smart form which worked excellently 😃

There’s an initial delay where the page will refresh for 100-300ms before redirecting to whatever href is set - but that’s alright as I don’t think anyone will care.

Excellent work as always Rob! This definitely looks something that could’ve been quickly googled but I don’t have much time to do that right now, so I really appreciate your prompt replies mate!

---

<div class="post-metadata">

**Author:** ![RobM](https://avatars.discourse-cdn.com/v4/letter/r/278dde/32.png) [@RobM](https://forum.pinegrow.com/u/RobM)\
**Post date:** [November 27, 2020, 10:28am UTC](https://forum.pinegrow.com/t/is-it-possible-to-redirect-to-a-page-after-submitting-the-smart-form/4551/5 "2020-11-27T10:28:01Z")

</div>

No problem - not much to be done about the delay, that is how long the mailer takes.

Chaining commands in Pinegrow is fairly powerful, it just takes a little bit of mind-chanage from how it is normally done with writing code.
