Programmatically create forms

I was wondering if there’s a way to create forms programmatically without actually saving them to the database.

I have a large site, with many forms, some of them quite complex. Most of them are sending stuff to third party applications.

I’d like to be able to create my forms in PHP (or json or whatever), with proper version control, with “hard coded” IDs so that I don’t have to worry to keep track of local vs production form IDs.

Is there a way to achieve this? Such as function/method to which I can pass a form object and it will render the form? (this way I can even use gettext calls to internatinalize labels instead of having to rely on WPML glue plugin or having form duplicates for different languages).

I’ve used GFAPI::add_form , but it’s only creating the form in the backend


There are no built-in methods for this and I’m not aware of any add-ons with a feature like this. The included methods for generating the form markup require the form id or title to be passed so the form object can be retrieved from the database. You could suggest including a method like this in a future release via the roadmap at

If I remember correctly, I believe that the MailChimp Gutenberg editor block does this…if not MailChimp, then another newsletter add-on.