Iubenda logo
Start generating

Documentation

Table of Contents

Consent Database for Gravity Forms

Have you generated a website using Gravity Forms and need to meet GDPR consent requirements?

Well, you’re in the right place. In this guide, we’ll take a look at GDPR consent proof requirements and how to add iubenda’s Consent Database to your Gravity Forms site.

→Jump to How to add the Consent Database to Gravity Forms

To put it simply, you do need GDPR proof of consent for your Gravity-Forms site, and here’s why:

Consent records are specifically required under the GDPR. Keeping a complete and thorough record of consent is required and is an essential part of privacy compliance. The records of proof are managed by you, the Data Controller. As a result, the GDPR requires you to keep “proofs” or records of consent that contain specific details that might prove that the consent received is genuine and therefore valid under the GDPR. Consent must be explicit, freely provided, and verifiable under the GDPR. You can read up more on iubenda’s Consent Database here.

These records should include a way of identifying the user, proof of consent, record of the consenting action, and the legal documents available to the user at the time of consent, among other things.

The following information should be recorded:

  • who provided the consent; 
  • when and how consent was obtained from the particular user; 
  • the consent collecting form they were presented with at the time of collection; and 
  • whatever conditions and legal documents were in effect at the time the consent was obtained.

You can read about the full requirements here.

iubenda’s Consent Database automatically records and manages GDPR & LGPD consent and privacy preferences for each of your users. You can read up more on iubenda’s Consent Database here.

How to add iubenda’s Consent Database on Gravity Forms

The following guide on how to integrate our Consent Database with Gravity Forms is designed specifically for the use of developers. We understand this is a complex guide please use this example as a starting point and talk with your technical team to customize it according to your specific scenario. 

Since Gravity Forms is not compatible with our WordPress plugin and conflicts may arise when using our Javascript method, we decided to create an example of integration using Gravity Forms action hooks and our Consent Database API.

To create a consent in Gravity forms you’ll need to:

  1. In the functions.php file, create a PHP function (see below) called save_consent() – this function contains the instructions to create a consent in our Consent Database
  2. After that, you’ll have to add a WordPress action to the gform_after_submission action hook

In doing so, the save_consent() is launched every time a form is sent.

//Creating the function that sends consent to ConS 
function save_consent(){
$consent_data = array(
"timestamp" => date('Y-m-d H:i:s'),
"subject" => array(
"full_name"=>$_POST["input_1_3"], //input sent via form (Please note: real name in the Gravity Forms is input_1.3, but dots (and spaces) in a variabile should be changed in _ 
"email" => $_POST["input_2"], //
),
"legal_notices" => array(
array(
"identifier" => "term"
),
array(
"identifier" => "privacy_policy"
)
),
"preferences" => array(
"privacy_policy_gform" => true
),
);
$req = curl_init();
curl_setopt($req, CURLOPT_URL, 'https://consent.iubenda.com/consent');
curl_setopt($req, CURLOPT_RETURNTRANSFER, true);
curl_setopt($req, CURLOPT_HTTPHEADER, array(
'ApiKey: YOUR PRIVATE API KEY',
'Content-Type: application/json'
));
curl_setopt($req, CURLOPT_POST, true);
curl_setopt($req, CURLOPT_POSTFIELDS, json_encode($consent_data));
$response = curl_exec($req);
}
//the number 8 is the ID of the form where we want to append the save consent function
add_action( 'gform_after_submission_8', 'save_consent', 10, 2 )

Please note:

If you have more forms, and you want to append the same save_consent function for all the forms you can change the add_action in this way:

add_action( 'gform_after_submission', 'save_consent', 10, 2 )

This function reads consent data coming from Gravity Forms via a POST request.

It contains an array, which is the PHP example you can find here in our Consent Database HTTP API documentation

What you should customize:

  1. Subject data: fields accepted are only full_name, last_name, first_name, email 

In our PHP function, you will find one or more of these keywords followed by the superglobal $_POST variable which contains the value of that, so you can create the consent with the values that the user filled in the form. 

You can find more information about the $_POST superglobal variable in the official PHP documentation.

For example, suppose that you have created a form using Gravity Forms that has the following HTML:

<form action="/action_page.php">
<label for="fname">First name:</label><br>
<input type="text" id="fname" name="fname" value="John"><br>
<label for="lname">Last name:</label><br>
<input type="text" id="lname" name="lname" value="Doe"><br><br>
<input type="submit" value="Submit">
</form>

You will customize this part of our example:

in this way:

"subject" => array(
"first_name"=>$_POST["fname"]
"last_name" =>$_POST["lname"];
),

Now, add your own Consent Database Private API Key in the following function, as shown below:

Please note that the Consent Database has 2 different keys, public and private, use always the private since the public one is not going to work with our API.

Next, you can also customize the preferences, they usually coincide with the checkbox that the user accepts when sending the form: "preferences" => array("privacy_policy_gform" => true)

But you can also decide to pass this value using the $_POST variable as we have done within the “subject” if you want to read it dynamically.

Lastly, you can customize the consent, passing also the proofs of consent, as we have done in this example

"proofs": [
{
"content": "proof_1",
"form": "proof_1 form"}] 

where “content” can be a recap of values inserted by the user in the form and “form” is the HTML code of the form filled by the user.

Customize the add_action( 'gform_after_submission_8', 'save_consent', 10, 2 ) with the ID of the form, you can find it in the Gravity Forms settings. If the ID of the form is 6754 then 'gform_after_submission_8'will be  'gform_after_submission_6754'

That’s it! Remember that this is an example and is a good starting point. We recommend talking with your technical team to customize the above according to your specific scenario.