0

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.

0

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.


Another approach.

  1. Create a special endpoint, let’s say submit with the sub-type step.

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 …

  1. 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.

  2. Again, when that form is processed lead to step 3 or a success message.

  • Can you link me to where they describe heirarchical custom post types - haven't heard of these before. – jac300 Jun 25 '13 at 18:44
  • Sorry - apparently hitting enter submits the comment. But I would also like to know if that would match the criteria for the following example: I have a form that creates a new company and a post generated from that form. Then I have a multiple forms for products based on the type of company. I still want to generate a product post based on the form for every submission. Let me know if that doesn't make sense. – jac300 Jun 25 '13 at 18:46
  • Oh, now I get what you are out for. I think another approach than my first suggestion would be better. – fuxia Jun 25 '13 at 18:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.