Everything You Need to Know About Gravity Forms Database Structure

  1. Gravity Forms SQL Tables
    1. Form Data
    2. Entries Data
    3. Add-On Data
  2. Where are these SQL Tables stored?
  3. Forcing Gravity Forms Database Updates
  4. Integrate Gravity Forms with a Database
  5. Final Thoughts

Gravity Forms is a plugin to create custom forms for a WordPress site. Since its release, it has developed into a mature, stable WordPress form plugin that webmasters have grown to trust to create advanced forms quickly. If you use Gravity Forms, the admin settings generally provide you sufficient cover to manage the structure and content of your forms. In this post, we discuss the structure of the Gravity Forms database.

Gravity Forms is a critical plugin for dynamic, interactive websites powered by WordPress today. It provides powerful features like drop-down WYSIWYG form creation and conditional logic to create multi-page forms. While the GUI of Gravity Forms can enable you to access the entirety of the plugin, special conditions may require the knowledge of the underlying database structure. If you find yourself in a situation where your database gets corrupted, knowledge of the database structure may be of help. Additionally, it may be a good idea to understand how you store and process the end user’s data from the frontend to the backend in the GDPR compliance era.

First, we explore what constitutes the Gravity Forms database — its SQL tables and their interlinkages. Then, we move on to various ways of accessing the Gravity Forms database, how you can force an update and integration of the database with a different source.

Gravity Forms SQL Tables

In this section, we discuss the new structure of the Gravity Forms database. We also assume that you used the “wp_” prefix for all WordPress tables during the installation of your WordPress site. If your site’s settings use a different prefix, it would appear in place of “wp_” for all table names below. In addition to this prefix, all Gravity Forms database tables have a “gf_” prefix for all table names.

We have divided this section into tables related to three broad categories — forms, entries, and add-ons. You can find the data of every interaction you have with the Gravity Forms plugin in one of the tables described below. The database tables for the Gravity Forms plugin contains all relevant data related to the plugin. These tables store form metadata, various form fields, saved data for form submission at a later stage and submitted form data. Any interaction through the Gravity Forms API also results in entries into the same database tables.

Form Data

The basic information about a form that one may create is stored in the table wp_gf_form. It contains the form name, date of creation, and whether the form is currently active. The table wp_gf_form_meta contains the metadata of each form, which includes display information and configuration information. The table wp_gf_form_view stores information on form views. Each row in the meta and view tables are linked to a single form in the wp_gf_form table.

Entries Data

When you submit a form in Gravity Forms, it creates an entry. The wp_gf_entry table stores details about the Entry Object. Any entry data for a form is stored in this table. The basic data elements of this table are the form to which it belongs, the user associated with the entry, related timestamps, and payment and transaction details if applicable. If your form has the “Save and Continue” feature, the table wp_gf_draft_submissions saves intermediate data until the user submits the form. Did you know you can edit entries on the front end too?

There are two other tables that support the wp_gf_entry table. The wp_gf_entry_meta table contains the meta description of an entry object. This metatable may also contain add-on details if present. If an entry contains entry notes, the table wp_gf_entry_notes stores the textual data.

Add-On Data

In addition to the form and entry tables, the Gravity Forms plugin creates three tables to support its add-ons. The wp_gf_addon_feed is the primary table that stores necessary information about any add-on. This table contains data on add-ons that may be linked to the wp_gf_entry table.

If an add-on requires the user to make a payment, the wp_gf_addon_payment_transaction and wp_gf_addon_payment_callback tables store the transaction and callback details, respectively.

Where are these SQL Tables stored?

While we have discussed the structure of the tables, there are many methods through which you can view these tables. If you use MySQL or MariaDB as your WordPress database, you can use phpMyAdmin to view the structure and contents of these tables. Alternately, MySQL, and MariaDB provide a command-line interface that lets you query the tables through the terminal.

Forcing Gravity Forms Database Updates

With the release of Gravity Forms 2.3, several tables were deprecated and should not be used. Future updates may also lead to changes in the database structure. Therefore, when you update the Gravity Forms plugin, you may encounter an error in the plugin due to the failure in the database modification.

Gravity Forms has a feature to manually run the database modification script after you have updated the plugin. In the WordPress admin dashboard, select the System Status option under the Forms menu. In the Database section, choose the option to “Re-run database upgrade” to port your database tables from the old structure to create new tables. As this process involves changing tables in your database directly, it is a good idea to backup your database in case the process fails and corrupts the plugin.

Integrate Gravity Forms with a Database

We have explored how Gravity Forms stores its data within the database that your WordPress site runs on. At this point, you may wonder whether it is possible to store the data of Gravity Forms in a different database, within the system that runs WordPress or in an external source.

While it is possible to achieve this integration, the easiest way to do so is through an add-on, wpDataTables. Once you have purchased and installed both Gravity Forms and wpDataTables, you can set up an external data source for an existing form with entries. You can also add wpDataTables data into a Gravity Form with GP Populate Anything. In case you are skeptical of starting the complex migration, wpDataTables provides a sandbox environment to test the whole process before you make a final decision. It is, however, difficult, though not impossible, to automate the process of complete migration from the existing database source of Gravity Forms.

Gravity Forms Google Sheets automatically syncs your Gravity Forms data with Google Sheets, which integrates with Data Studio (aka Looker Studio), BigQuery, and others.

Final Thoughts

In this tutorial, we discussed the need to understand the structure of the Gravity Forms database. We explored various tables that form the base for the functioning of Gravity Forms. Next, we looked at the process of forced database modifications for the plugin on an update. Finally, we analyzed the process of integration of Gravity Forms with an external database.

You need Gravity Perks to get the full power of Gravity Forms! Buy Gravity Perks today to all of our galactic Gravity Forms plugins!

Comments

    1. Samuel Bassah
      Samuel Bassah Staff May 19, 2021 at 6:44 am

      Hi CV,

      Nested Form entries are stored just like normal Gravity Forms entries. So yes, it also applies to Nested Forms.

      Best,

  1. NB
    NB January 13, 2021 at 12:32 am

    Ryan, would be great if you threw in some sample MySql queries – e.g. show me all the entries (field names and entry values) for a specific form, etc.

    Reply
    1. Ryan Donovan
      Ryan Donovan January 13, 2021 at 10:02 am

      Hello There, Thank you so much for the recommendation. We have noted this and may add this as we update our documentation. Thank you so much again!

  2. Jack
    Jack May 28, 2020 at 12:50 pm

    Thanks I am looking for the database record where the chosen currency is stored it must be in the database and not on php level I think that because I have a multi/networked site with for each subsites own currencies

    Reply
    1. Ryan Donovan
      Ryan Donovan May 28, 2020 at 2:38 pm

      Hey Jack, Just confirmed with the development team and GFCommon::get_currency() will provide them with the current currency that Gravity Forms is using.That’s a PHP function/method straight from Gravity Forms. Something to note is it does pull the rg_gforms_currency option in the wp_options table on the database if it’s set.

  3. jack Schneider
    jack Schneider May 28, 2020 at 5:21 am

    It is a nice description of the database usages but I mis the place where the gravity options are stored in the database probably in the wp_options table but I can not find them. I need that because with the default currency must be filled in and we have a lot of subsites.

    Gravity forms has been update and somtimes the currency is not find but form execution crashes when currency is empty. even when there is no currency field on the form.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

  • Trouble installing this snippet? See our troubleshooting tips.
  • Need to include code? Create a gist and link to it in your comment.
  • Reporting a bug? Provide a URL where this issue can be recreated.

By commenting, I understand that I may receive emails related to Gravity Wiz and can unsubscribe at any time.

Grab a bundle of free Gravity Forms plugins

Enter your email and receive our most popular free plugins and snippets, plus access to hundreds of others.

This field is for validation purposes and should be left unchanged.