Last active
May 24, 2018 19:00
-
-
Save Shelob9/c06aea9f81c03556f24eba9ba2c43a48 to your computer and use it in GitHub Desktop.
Some examples of Caldera Forms GDPR APIs See: https://calderaforms.com/doc/gdpr-api/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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