[Resolved] Create flow for user from parent cred form to child form and linking them
This support ticket is created 7 years, 2 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.
First you need to create a page and add that child form to the page. The next step is to use the redirect hook to provide the child page with the parent page ID after you have created the parent.
add_filter('cred_success_redirect', 'custom_redirect',10,3);
function custom_redirect($url, $post_id, $form_data)
{
if ($form_data['id']==12)
return 'mychildform-page-url?parent_{parent_CPT_slug_here}_id='.$post_id;
return $url;
}
Add the hook above to your functions.php file and then replace the relevant areas such as the url link the parent cpt and the form ID.
Please try this and let me know if it helps.
Thanks,
Shane
Hi Shane, apologies for this. The more I understand the more I see the problem.
If you look at the flow process I have missed some important points out:
1. A user will only ever create 1 website.
2. The Custom Post Type A will be create several times using the same form e.g. on a page after submission the form is shown again so they create CPT Type A 1, CPT Type A 2, CPT Type A 3 until they have completed the number relevant to them. Each one though needs to assigned to the original Parent Post Type - Website (only 1 per user).
3. On the page with the website creds form for creating CPT Type A posts there is a button that then takes them to the next creds form.
4. This new creds form page creates CPT Type B posts. Each of these needs to be linked to the Parent Post Type - Website (only 1 per user).
5. The user will then create several of these CPT Type B posts - CPT Type B 1, CPT Type B 2, CPT Type B ...Each one needs to be linked to the Parent Post Type - Website.
So based on this and my understanding I think the question is - can a creds form based on a user be linked to a single parent post type using a filter or code or short code.
The website form are as follows if you want to take a look:
Parent Post Form hidden link
Child Type A form hidden link
Child Type B form hidden link
Hi, sorry for the delay in getting back to you. I don't think that will work. If you look at the flow diagram you may see why:
The website form are as follows if you want to take a look:
Parent Post Form hidden link
Child Type A form hidden link
Child Type B form hidden link
To recap:
There will only be one website created by one user.
Each user will therefore after creating the site have one website id associated with them.
After completing the website the url data is passed to the next form, however
Each user can create more than one child post.
So the website form 2 they create more than one post - the question then is can the url redirect assign the parent post id on the creation of the 2nd, 3rd...child post?
The website form 2 has a button on it that once people have finished creating the child posts for form 2 takes them to the next form, if the filter only works on url parameter I can't see this working either.
A question is can a filter or hook/action be used that works on the submit or creation of a cred post that assigns it to the parent post (only one parent post will exist). So a query to the database for user find parent post id and then use this to identify parent id and assign to any child post created?
Also the code should work its just that we are not providing the right information. So after child type A is created the user should get redirected to Child Type B which is on a different page correct?
Also the user does have the option to assign the parent to the child when the child is created because there is a dropdown on the form to assign the parent to the child.
Hi, I tested this and as I suspected it doesn't work. The parent id is passed to the first child post created but then every other one is an orphan. Is there a way to filter or link each creation to the parent post via user id.
So there will only be one website per user but multiple child posts.