Home › Forums › Quform WordPress › Click submit -> do stuff with form data -> redirect
- This topic has 3 replies, 2 voices, and was last updated 1 year, 9 months ago by Ally.
- AuthorPosts
- February 8, 2023 at 7:07 am #35139wp_tc_questionsParticipant
I’m trying to build a basic wordpress app to collect form data, do some stuff with the data, and then redirect.
Previously I would pull this off with a wordpress template….
if(isset($_POST[‘submit’]))
{
//do some stuff
wp_redirect( $url );
exit();
}I’ve found QuForm….and I’m now trying to switch gears and use the quform_post_process hook in functions.php….
quform_post_process_x() {
//do some stuff
wp_redirect( $url );
exit();
}I’m running into the “AJAX error”
My question is……is there a better approach to what I’m trying to accomplish? if not …..is there a special way to pull off the redirect in the post_process_x hook?
February 8, 2023 at 11:07 am #35142AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
February 9, 2023 at 4:23 pm #35151wp_tc_questionsParticipantFWIW, I got the functionality I was trying to achieve, thanks.
I went with configuring the confirmation redirect in the UI
Then in functions php, went with the quform_post_validate hook, and if I want to short circuit the redirect I can return an error.
add_filter(‘quform_post_validate_1’, function (array $result, Quform_Form $form) {
//do some stuff
if(//stuff did not work) {
$result = array(
‘type’ => ‘error’,
‘error’ => array(
‘enabled’ => true,
‘title’ => ”,
‘content’ => ‘It’s Broken.’
)
);
}
return $result;
}, 10, 2);February 10, 2023 at 10:41 am #35155AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
- AuthorPosts
- You must be logged in to reply to this topic.