Calculated Fields Form Blog

Tips and cases of use for a successful WordPress website with calculated forms.

Blog / How to store, update or delete entries in third-party databases

How to store, update or delete entries in third-party databases

How to use the data collected by the form to interact with databases other than the plugin's database or tables.


It is not a novelty that the "Calculated Fields Form" plugin allows to store the information collected by the form in databases or tables other than the plugin. However, this feature is only available for the Developer and Platinum versions and requires editing the "cp_calculatedfieldsf_insert_in_database.php" plugin file.

Editing this file gives developers a great freedom, but requires some skills in SQL and PHP. In addition, since the code in this file is evaluated with each form submission, the process can be complicated when we want to define insertion queries that only affect some of the forms on the web site.

An disadvantage of this method is that database queries are executed when the form is submitted. But there are situations where it would be required to evaluate the insertion queries after receiving payment confirmation from the payment gateways integrated to the form.

To facilitate the implementation of the queries, as well as solve the disadvantages described above, we have implemented the complementary plugin "Database Queries for Calculated Fields Form".

In contrast to the "cp_calculatedfieldsf_insert_in_database.php" file, the "Database Queries for Calculated Fields Form" plugin can be used with the Professional, Developer, and Platinum versions of the plugin.

The "Database Queries for Calculated Fields Form" plugin includes a new section in the form's settings to define INSERT, UPDATE, and DELETE queries (as many queries as you need) to evaluate after submitting the form, or receive the payments confirmation.

The plugin allows you to implement queries in a completely visual way. You don't need to have SQL or PHP knowledge, just decide the fields to be used to fill the database columns, or for filtering the rows to update or delete.

Settings

The plugin interface is very intuitive and versatile. It allows you to define multiple queries and deactivate queries you don't need. It includes a drop-down menu to select the type of query (INSERT, UPDATE, DELETE). A section where you can configure the database on which to evaluate the query (the website database, or another database by entering its hostname, username, password, and database).

Database

The interface allows you to define the query by entering its components.

Query components

Or, if you need more control over the query, you can enter it manually.

Custom query

Finally, there are two checkboxes. The first one to run the query only after receiving the payment confirmation. And the second checkbox to create logs in the error logs file for the query errors.