Skip Navigation

[Resolved] Form Flow

This support ticket is created 6 years, 3 months ago. There's a good chance that you are reading advice that it now obsolete.

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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

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 5 replies, has 2 voices.

Last updated by ScottM9386 6 years, 3 months ago.

Assisted by: Christian Cox.

Author
Posts
#1089581

Hi,
Do I have this right?
If I want the child parent selector to be pre-filled out then:
1. Create form for parent and child.
2. on submit from parent form redirect MUST go to parent just created (can't go to child form if I want parent selector pre-filled with just created parent)
3. On page of newly created parent I put link to child form - then parent selector will be pre-filled.

Since my parent has 3 different post type children this is not a great work flow. (back and forth, back and forth...)
Is the above correct?

Thanks,
Scott.

#1089588

2. on submit from parent form redirect MUST go to parent just created (can't go to child form if I want parent selector pre-filled with just created parent)
You can use the cred_success_redirect API to skip this step and go directly to the child form with URL parameter applied. The new parent form must be configured to "redirect to another page" after form submission. Then add this custom code to your child theme's functions.php file:

add_filter('cred_success_redirect', 'custom_child_redirect',10,3);
function custom_child_redirect($url, $post_id, $form_data)
{
    if ($form_data['id']==12345)
        return $url . "?some-param=" . $post_id;
    return $url;
}

Change 12345 to match the new parent post Form ID, and change some-param to match the parent post select field attribute urlparam in the new child post Form.
More information about this API here: https://toolset.com/documentation/programmer-reference/cred-api/#cred_success_redirect

#1089613

Thanks Christian!

#1089616

Thinking about it some more...not sure would work because my set-up is a multi-site with each user having their own subsite, so there's no static URL.

Thanks.

#1089618

The $url variable isn't static in this example, it represents whatever you choose in the Form redirect settings. So on one subsite, everyone will be redirected to one URL with different URL parameters. On another subsite, everyone will be redirected to one other URL with different URL parameters. Am I understanding correctly? If the redirect URL is consistent per subsite, then this approach will be fine. For example:
Subsite 1 parent Form redirects to:
subsite1.mainsite.com/create-child-post?parent-id=12345
Subsite 2 parent Form redirects to:
subsite2.mainsite.com/create-child-post?parent-id=23456
Subsite 3 parent Form redirects to:
subsite3.mainsite.com/create-child-post?parent-id=34567
etc.

#1091830

Thanks Christian,

I did it another way....as I don't understand but also I don't know what the subsite might be called, it's created on the fly by the user using wpUltimo. They choose their own name.

Regards.