I have a form that users fill out. When they finish, they are redirected to a 3rd party site to set up payment options. After completing the payment process, they are sent back to my site with a variety of $_POST variables.
My plugin needs to create a thank you page based on those POST variables. It’s a simple little page with a title and a few paragraphs of text.
I do not want these pages to be stored in the database. They will be unique to each transaction.
I attached a function to init
that parses the $_POST data (after sanitizing, of course.) That function creates two global variables: $my_title
and $my_content
I’m not sure how to turn those into a page for the user, though.
The payment system will send users to www.mysite.com/thank-you
So far, I have a filter on rewrite_rules_array
to add my url:
function my_rewrite_rules( $rewrite_rules) {
$rule = array('thank-you/?$' => 'index.php?formresult=thank-you');
$rewrite_rules = $rule + $rewrite_rules;
return $rewrite_rules
}
I filter query_vars
to add mine:
function my_insert_qv($vars) {
array_push($vars, 'formresult');
return $vars;
}
Then, I have an action on template_redirect
where I think the action should be. Maybe this is the wrong path.
function my_template_redirect() {
gloval $wp;
$qvs = $wp->query_vars;
if (array_key_exists( 'laundry', $qvs && $qvs['laundry'] == 'thank-you' ) {
global $wp_query;
$wp_query->set( 'is_404', false );
// ... now what?
}
}
How can I show the user a page that loads the default page template from the active theme and shows my dynamic title and content?