I'm trying to pass field values (categories in checkboxes) from my Toolset form into a Gravity Form on the next page.
So Step 1 is users create a post using Toolset, then because I can't either a. update that users registration or b. pass those values to Mailchimp, I need the user to proceed to 'Step 2'.
Step 2 is a Gravity Form, where the user's registration is updated and their Mailchimp details are updated. I want to pass values from the 'taxonomy' fields in the CRED form into the Gravity Form, because users don't want to answer the same questions twice.
I'm using this snippet from another forum post to edit the URL:
/**
* Customise redirect URL
*/
function tssupp_custom_redirect( $url, $post_id, $form_data ){
if ( $form_data['id'] == '244' ) { // Edit form id
$url .= '?yearlevel=' . $value;
}
return $url;
}
add_filter( 'cred_success_redirect', 'tssupp_custom_redirect', 10, 3 );
And my new URL looks like this: hidden link.../?yearlevel&cred_referrer_form_id=244
But the field value has not been passed through. Please let me know:
a. what is wrong with the snippet above?
b. do I need to add another class-thing into the CRED shortcode in the form?
b. what else do I need to add into the CRED form to pass the values correctly?
This is a showstopper for me, and the only way to get around the limitations of Toolset. I've spent hours trying to make it work and it's driving me up the wall. Please let me know what else I need to do. Thanks,
Hi Lucy,
Thank you for waiting.
I performed some tests on my website and the following code snippet works, to pass on the selected taxonomy term IDs:
add_filter('cred_success_redirect', 'custom_redirect',10,3);
function custom_redirect($url, $post_id, $form_data)
{
if ($form_data['id']==244) {
$url_new = $url."?";
foreach ($_POST['year-level'] as $key => $value) {
$url_new .= '&yearlevel[]=' . $value;
}
}
return $url_new;
}
Note: Please make sure that you're using the correct form's ID ( 244 ) and the taxonomy field's slug ( year-level ) in the code snippet.
I hope this helps and for more personalized assistance around custom code, you can also consider hiring a professional from our list of recommended contractors:
https://toolset.com/contractors/
regards,
Waqar
Thank you! You are a legend!
You're very welcome Lucy.
For a new question/concern, please open a new ticket - we're here to help!
Hi Waqar,
I've hit a snag -
When the form is used to create a child post (like in https://toolset.com/documentation/post-relationships/selecting-parent-posts-using-forms-create-child-items/) it doesn't work. I'm guessing this is because the form is already passing some information in the URL which takes precedence?
It works fine when it's not being used to create a child post.
Is there something I need to add to the snippet?
Thanks
Hi Lucy,
Can you please share specific details about the page and the form that you used for testing and it didn't work?
Please also let me know where was the snippet for "cred_success_redirect" added.
I'll need to fully understand which part is working and which isn't, to guide accordingly.
regards,
Waqar