PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Submit multiple posts in one go

  1. I'm building a system where a registered user can submit posts (bound to a custom post type) via an online form. Now I would love to build the page so, that the user can submit multiple posts without leaving the page, i.e. the form would either appear multiple times on the page, or there would be similar fields appearing multiple times. In the end, user could click one master "Submit", and all the rows would individually be submitted as a post.

    Please see the linked image for a rough sketch on the desired form setup.

    Submit multiple posts in one go

    For this to work, I would also need to hide the labels for the fields etc, but I think that would be doable with just modifying them via CSS.

    Any ideas on how I could accomplish this?

    Posted 9 years ago on Sunday November 4, 2012 | Permalink
  2. You could hide the labels and whatnot with CSS so that's no problem.

    To create multiple posts, according to your screenshot, you would not use the Post Fields from the form builder. It looks like you could use the List field (in the advanced field types.) That would enable the input of all the data. Then you would have to use the gform_after_submission hook to create all the posts. The function you run with the gform_after_submission hook would use the WordPress function wp_insert_post to create posts. You'd loop through all the fields in the form and insert all the information required for wp_insert_post.

    It does not seem too complicated, but the posts will be created by a function you hook to gform_after_submission, rather than by using Post fields in your form.

    Let us know if you need additional information to get started.

    Posted 9 years ago on Monday November 5, 2012 | Permalink