Problem: I would like to make the process of submitting repeatable field groups (RFGs) in Forms simpler. Since I cannot create RFGs in the same Form that manages a parent post, I would like to redirect back to the parent post after the User creates an RFG in Forms.
Solution: You can use the Forms redirection API to redirect to any custom post or page. In the Form settings, you must set up some redirection. It doesn't matter which page or post you choose in the Form settings, but you must choose something for redirection. Then add the following custom code in your child theme's functions.php file, or in a custom code snippet in Toolset > Settings > Custom Code:
add_filter('cred_success_redirect', 'custom_redirect_rfg_editor',10,3); function custom_redirect_rfg_editor($url, $post_id, $form_data) { $forms = array( 12345 ); $rfg_slug = 'your-rfg-slug'; if ( in_array( $form_data['id'], $forms ) ) { $parent_id = toolset_get_related_post( $post_id, $rfg_slug ); return get_permalink($parent_id); } return $url; }
Replace 12345 with the ID of the RFG form, and replace your-rfg-slug with the slug of your RFG. Then this code will automatically redirect to the single parent post after submitting the form.
Relevant Documentation:
https://toolset.com/documentation/programmer-reference/cred-api/#cred_success_redirect
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | - | - |
13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | - | - |
Supporter timezone: America/New_York (GMT-04:00)
This topic contains 7 replies, has 2 voices.
Last updated by 4 years, 7 months ago.
Assisted by: Christian Cox.