This forum is no longer open and is for reading/searching only.
Please use our new MachForm Community Forum instead.
MachForm Community Forums » MachForm 2
Dynamic redirect URL after submission
Started 14 years ago by jhinkle | 9 posts |
-
I'm building a redirect URL string after the submission of the form and need help as to where it goes.
I tried putting it in the post-functions.php file after the below lines of code:
$process_result['form_redirect'] = $form_redirect;
$process_result['old_values'] = $form_data;
$process_result['error_elements'] = $error_elements;I tested it and it seems to just be going to the text "Success! Your submission has been saved!"
Below is my code that dynamically builds the redirect URL:
if ($form_id == 4 ) {
$productID = 46;if (!empty($_POST[$table_data['element_34_1']])){
$productsID = $productID . ',44{1}';
}
if (!empty($_POST[$table_data['element_34_2']])){
$productsID = $productID . ',44{2}';
}
.
.
.$process_result['form_redirect'] = "http://www.yourdomain.com/catalog/addproducts.php?product_id=" . $productsID;
}Posted 14 years ago # -
Can you let me know at what line number exactly you put the code above? There are similar codes on some different lines, this might be the cause.
Also, do you have "form review" enabled on your form?
MachForm Founder
Posted 14 years ago # -
Redityo told me to put it after line 915
Yes, I have "form review" enabled on this form.
Posted 14 years ago # -
Ah.. I see. Most likely redityo was assuming that "form review" wasn't enabled.
The code above only work when you have form review turned off.If you have form review, you need to follow exactly like this post:
http://www.appnitro.com/forums/topic/custom-action-url-and-usage-field-data?replies=16#post-5246MachForm Founder
Posted 14 years ago # -
Adding the session variable fixed my problem, thanks! But now I'm running into a problem with the URL not building properly. Even though I have checked some checkboxes on my form, it's not appending my "productID" to the string variable (which in turn, appends to the redirect URL). Can you double check to see if I'm coding it correctly:
if ($form_id == 4 ) {
$productID = 46;
// Mens Shirts
if (!empty($_POST[$table_data['element_34_1']])){
$productID = $productID . ',44{1}1';
}
if (!empty($_POST[$table_data['element_34_2']])){
$productID = $productID . ',44{1}2';
}The only "productID" that is appended to the redirect URL is "46" - the default value as seen above.
Posted 14 years ago # -
Ah.. yes, you need to do one more thing.
Edit your post-functions.php file, search around line 1241 for this code:
return $process_result;
change it to become:
$_SESSION['table_data'] = $table_data; return $process_result;
then adjust your current code to be like this:
$table_data = $_SESSION['table_data']; if ($form_id == 4 ) { $productID = 46; // Mens Shirts if (!empty($table_data['element_34_1'])){ $productID = $productID . ',44{1}1'; } if (!empty($table_data['element_34_2'])){ $productID = $productID . ',44{1}2'; }
MachForm Founder
Posted 14 years ago # -
I might have to send you my post-function.php file, because not only does my URL not build, but now it doesn't properly show the review page correctly.
Posted 14 years ago # -
I even tried to complete the form without the review page, and it still wouldn't build the URL properly.
Posted 14 years ago # -
Removing _POST when referencing the checkboxes fixed both of my problems ... Thanks Redityo!
Posted 14 years ago #
Reply
You must log in to post.