Open in ChatGPT
Ask questions and chat with this page directly in ChatGPT

Intro

Gravity Forms is a powerful and easy-to-use WordPress forms plugin. I have worked on countless tutorials, which can be found here.

In short, the plugin provides one with a wonderful GUI-based form builder and a set of extra features, to mention a few: Conditional Logic, Custom Notifications, 3rd party integration, etc. I use this plugin with pretty much every project I work on.

In this short tutorial, I’ll show you how to overcome the problem of having the same form duplicate Gravity Forms form embeded on a single WordPress page. The details of why this won’t work are explained thoroughly at: https://docs.gravityforms.com/embedding-one-form-multiple-times-per-page/.

Duplicate Gravity Forms form

One of the problems with duplicate Gravity Forms Form form is the fact that both of the forms submit at once.

Take on the duplicate Gravity Forms form

My take on that problem is quite simple:

  1. Duplicate the form you want to use.
  2. Place it anywhere on the page.
  3. Upon its submission, create an entry associated with the Main Form.

The above may come in handy and may be needed in plenty of situations:

  1. You export entries elsewhere regularly, and you want to avoid having to deal with multiple forms.
  2. You prefer to manage all your entries associated with one page from one place.

The code

I think that the code should be self-explanatory, although there are a couple of important things to bear in mind:

  1. We’re using the after_submission_hook, which has its pros and cons (say, some SPAM entries may incorrectly land in your inbox).
  2. Due to the GF core array_merge_recursive hidden behind the API, we have to unset some of the $_POST global values to avoid incorrect values being passed to the API Read more here: https://gist.github.com/rxnlabs/1bd931bb0261e53e882e9e7315bae8dc.

 

  • Have you any questions?
  • Are you dealing with similar problems, and you haven’t got the skills to take care of them yourself?

Ping me via the Contact Form 🙂