Home › Forums › Quform WordPress › Redirect to page if page id equals X
- This topic has 2 replies, 2 voices, and was last updated 7 years, 9 months ago by brabox.
- AuthorPosts
- August 2, 2016 at 3:51 pm #19618braboxParticipant
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
August 3, 2016 at 5:41 pm #19624AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
August 8, 2016 at 9:07 pm #19642braboxParticipantThank you so much Ally!
It worked!Problem solved.
- AuthorPosts
- You must be logged in to reply to this topic.