Skip to content

Instantly share code, notes, and snippets.

@Shelob9
Last active May 24, 2018
Embed
What would you like to do?
Some examples of Caldera Forms GDPR APIs See: https://calderaforms.com/doc/gdpr-api/
<?php
/**
* For the form with the ID CF12345 disabled GDPR privacy exporter and eraser are enabled
*/
//Get form config
$form = Caldera_Forms_Forms::get_form( 'CF12345' );
//Set as disabled
$form = Caldera_Forms_Forms::update_privacy_export_enabled($form, false );//does not save
//Save form
Caldera_Forms_Forms::save_form( $form );
<?php
/**
* For the form with the ID CF12345 enable GDPR privacy exporter and eraser are enabled
*/
//Get form config
$form = Caldera_Forms_Forms::get_form( 'CF12345' );
//Set as enabled
$form = Caldera_Forms_Forms::update_privacy_export_enabled($form );//does not save
//Save form
Caldera_Forms_Forms::save_form( $form );
<?php
/**
* For the form with the ID CF12345 get all email identifying fields
*/
//Get form config
$form = Caldera_Forms_Forms::get_form( 'CF12345' );
//Return flat array of field IDs
Caldera_Forms_Forms::email_identifying_fields($form, true );
//Return array of field configs
Caldera_Forms_Forms::email_identifying_fields($form );
<?php
/**
* For the form with the ID CF12345 check if field with ID fld_12345 is an email identifying fields
*/
//Get form config
$form = Caldera_Forms_Forms::get_form( 'CF12345' );
Caldera_Forms_Field_Util::is_email_identifying_field( 'fld_12345', $form );
<?php
/**
* For the form with the ID CF12345 check if privacy exporter and eraser are enabled
*/
//Get form config
$form = Caldera_Forms_Forms::get_form( 'CF12345' );
//True if enabled, false if not
$enabled = Caldera_Forms_Forms::is_privacy_export_enabled( $form );
<?php
/**
* Find first 25 entries of the form with he ID CF12345 where email identifying fields have the email Roy@HiRoy.club
*/
$form = Caldera_Forms_Forms::get_form( 'CF12345' );
$pii_query = new Caldera_Forms_Query_Pii(
$form, //Form configuration
'Roy@HiRoy.club', //email address to lookup
new Caldera_Forms_Query_Paginated($form, \calderawp\CalderaFormsQueries\CalderaFormsQueries())
);
//Get page 1
$results = $pii_query->get_page(1);
//total items for page 1
$count = $results->count();
if( 0 !== $count ){
//Get page 2
$results = $pii_query->get_page(2);
}
<?php
/**
* For the form with the ID CF12345 mark field with ID of fld_8712345 as email identifying field
*/
//Get form config
$form = Caldera_Forms_Forms::get_form( 'CF12345' );
//Use same abstraction used in REST API callbacks for convince
$privacy = new Caldera_Forms_API_Privacy($form);
$email_fields = [
'fld_8712345',
]; //must be array, there can be multiples
$privacy
->set_email_identifying_fields($email_fields) //set email fields, does not save
->save_form(); //Save
<?php
/**
* For the form with the ID CF12345 mark fields with IDs fld_8768091 and fld_9970286 as PII fields
*/
//Get form config
$form = Caldera_Forms_Forms::get_form( 'CF12345' );
//Use same abstraction used in REST API callbacks for convince
$privacy = new Caldera_Forms_API_Privacy($form);
$pii_fields = [
'fld_8768091',
'fld_9970286',
];
$privacy
->set_pii_fields($pii_fields) //set PII fields, does not save
->save_form(); //Save
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment