• Resolved tislars

    (@tislars)


    Hello,

    I am creating a small form with multiple questions. If the answers are correct, I want to redirect the user to a different page. However, what hook is able to do this? Because I tried numerous hooks, but the wp_redirect() will not redirect the user to a different page. After submission and reloading, the user stays on the same page as the form.

    This is my code:

    add_action('forminator_custom_form_submit_before_set_fields', 'handle_project_submission', 20, 3);
    function handle_project_submission($entry, $form_id, $form_data_array)
    {
    if ($form_id == 46) {
    $correct_answers = ['foundation', 'yes', 'europe', 'education-and-development'];

    if (
    isset($_POST['radio-1'], $_POST['radio-2'], $_POST['radio-3'], $_POST['radio-4']) &&
    $_POST['radio-1'] === $correct_answers[0] &&
    $_POST['radio-2'] === $correct_answers[1] &&
    $_POST['radio-3'] === $correct_answers[2] &&
    $_POST['radio-4'] === $correct_answers[3]
    ) {
    $nonce = wp_create_nonce('quickscan_nonce');
    $url = add_query_arg([
    'submission' => 'project',
    '_submissionnonce' => $nonce,
    ], site_url('/submit-project/'));

    wp_redirect($url);
    exit;
    }
    }
    }

    Can someone help me by handling the request and redirect the user to a different page?

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.