On our Wordpress site, we have a form that consists of a series of (radio button style) questions. Depending on which answer the user provides to a particular question, we'd like to show the user a different form. That is, we would like to link multiple forms to our one main form. Is this possible? If so, can someone explain how to do this, or point me to any kind of resource that might help? I am very new to Wordpress.
You could create a hierarchical custom post type and create a post for each form. Child forms are then set under a parent, their slug or a post meta field connected to the answers of their parent form.
When the form is submitted, you use the answer to select the best matching child and the you show that child form.
- Create a special endpoint, let’s say
submitwith the sub-type
On the main page, show the form. When the submission is a
POST request, validate the submitted data and either show the same for again to correct user errors or …
Create a new post for that company with
wp_insert_post(). This function returns a post ID. Redirect the user to the next step (
/submit/step/2) and show the next form. Add the post ID as hidden field, and set a cookie for the user, so you can track the progress.
Again, when that form is processed lead to step 3 or a success message.