Click submit -> do stuff with form data -> redirect

Home Forums Quform WordPress Click submit -> do stuff with form data -> redirect

This topic is: resolved
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #35139
    wp_tc_questions
    Participant

    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?

    #35142
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

    #35151
    wp_tc_questions
    Participant

    FWIW, I got the functionality I was trying to achieve, thanks.

    I went with configuring the confirmation redirect in the UI

    How do I set up the form to redirect to another page?

    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);

    #35155
    Ally
    Support Staff

    You don't have permission to view this content. Please log in or register and then verify your purchases to gain access.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.
Be inspired. © 2024 ThemeCatcher Ltd. 20-22 Wenlock Road, London, England, N1 7GU | Company No. 08120384 | Built with React | Privacy Policy