Redirect to page if page id equals X

Home Forums Quform WordPress Redirect to page if page id equals X

This topic is: resolved
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #19618
    brabox
    Participant

    Hello,
    I have been using a code provided by you for a couple of years which works great!

    Here is the working code (example)

    function calculator1($url, $form)
    {
    $data = array(
    'email' => $form->getValue('iphorm_15_1'),
    'pickupyesorno' => $form->getValue('iphorm_15_2'),
    'telefone' => $form->getValue('iphorm_15_3'),
    'country' => $form->getValue('iphorm_15_4'),
    );
    $data = array_map('rawurlencode', $data);
    $url = add_query_arg($data, 'https://www.domain.com/calc1/');
    return $url;
    }
    add_action('iphorm_success_redirect_url_15', 'calculator1', 10, 2);

    That works great!
    But i now need to redirect the form to a page depending on which page the form presents itself.
    Example, iphorm_15 is on page Calc1 (page-id-10) and it redirects to (calc-result1 page). Is there a way i can add a code which does: If iphorm_15 is on page Calc1 (page-id-10) redirect to X or else, if on page Calc2 (page-id-15) direct to Y.

    I did try something like this:

    function calculator1($url, $form)
    {
    $data = array(
    'email' => $form->getValue('iphorm_15_1'),
    'pickupyesorno' => $form->getValue('iphorm_15_2'),
    'telefone' => $form->getValue('iphorm_15_3'),
    'country' => $form->getValue('iphorm_15_4'),
    );
    $data = array_map('rawurlencode', $data);
    if(is_page(15)){
    $url = add_query_arg($data, 'https://www.domain.com/calc1/');
    return $url;
    } else {
    $url = add_query_arg($data, 'http://www.domain.com/calc2/');
    return $url;
    }
    }
    add_action('iphorm_success_redirect_url_15', 'calculator1', 10, 2);

    Thank you,

    Marco

    • This topic was modified 7 years, 9 months ago by brabox.
    • This topic was modified 7 years, 9 months ago by brabox.
    #19624
    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.

    #19642
    brabox
    Participant

    Thank you so much Ally!
    It worked!

    Problem solved.

Viewing 3 posts - 1 through 3 (of 3 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