Sometimes you may want to show users a preview of their submitted form data with a custom message. In this tutorial, we'll redirect users to another page with a confirmation message. You could show all the form entries, but it depends on your use case.
Firstly, we need a form widget with name, email, subject, and message field.
From Actions After Submit, select Dynamic Redirect and paste the internal page URL with the parameter. e.g.
https://yoursite.com/preview/?uname=[form:name|str_replace(' ','_')]&usubject=[form:subject|str_replace(' ','_')]
Here we have assigned form input values to custom parameters named "uname" & "usubject", you can use any other name for your parameter and fetch the assigned value to a parameter with a get function.
In value, we have also replaced spaces with "_" (underscore) to get the exact value on return if we replace underscores with spaces.
Click here to learn more about Dynamic Redirect URL parameters.
Note: name is a reserved term and may cause a 404 error. Notice we used name. Also, remember to replace "yoursite.com" with your domain URL.
Finally, we'll display the form parameters with tokens using the text below.
Hello [system:get:uname|str_replace('_',' ')|sanitize_text_field], your subject [system:get:usubject|str_replace('_',' ')|sanitize_text_field] has been submitted.
Note: To avoid XSS attacks append the
sanitize_text_field() WP function.
The result should look like this.