CCPA Framework Developer Documentation

 

The developer documentation can help you customize your user’s privacy experience. Developers built the CCPA framework for developers. Every part of the plugin is extendable, and you can override pretty much any behavior built in the plugin. You can add and remove elements from the Privacy Tools page in both the front-end and the dashboard. You can override each template used in this plugin.

Note that even though this doc contains everything you need to make your custom-built features or plugins CCPA-compliant, this is just the super-brief ‘beta’ version of our developer docs. We’re currently putting together more detailed documentation – stay tuned! If you spot any mistakes or find something unclear, don’t hesitate to ask!

 

CCPA Framework

Data Subjects

The CCPA Framework identifies data subjects by their email. All actions and filters have $email as one of the parameters – it refers to the email of the data subject whose data is being processed.

Actions With Data

Downloading a data subject’s data

When an admin or data subject downloads their data, it’s passed through a filter. You can add custom data there.

<php add_filter('ccpa/export', 'filter_ccpaexport', 10, 4); function filter_ccpaexport($data, $subjectemail, $datasubject, $format){ // do something with $data // return $data } ?>

The variable $data is simply an array of key-value pairs, containing all the downloadable data of that data subject. You can have nested arrays inside it. The same filter is triggered both when exporting data as HTML or as JSON. Find data belonging to a data subject on your website with this filter. Don’t forget to return $data! If you’d like to change the default JSON format to something else, you can use the following action.

Anonymizing Data

To do something when a data subject is anonymized, you can use the following action:

<?php add_action('ccpa/data-subject/anonymize', 'ccpa_anonymize_data', 10, 2); function ccpa_anonymize_data($email, $anonymizedId) { // do something here }

The second parameter, $anonymizedId refers to the anonymous, randomly generated ID that is used to tie bits and pieces of data together (but it’s still anonymous). For example, if a user is anonymized, then $anonymizedId will be stored in their usermeta table. If, for example, a Gravity Forms submission is also made using the same email, then the email will be replaced with the same anonymous ID, allowing you to connect it to the anonymized user. This might be useful for analytics, for example.

If the data subject has a user account, the user will be anonymized on the same action at priority 100. This means you can still access it if you set the priority to 10, for example.

Note that if the Delete Action is set to “notify”, then this action is triggered when the admin anonymizes the data subject, not when the data subject clicks on “delete everything” button.

Read about what exactly happens when a data subject is anonymized.

Deleting Data

To do something when a data subject is deleted, you can use the following action:

<?php add_action('ccpa/data-subject/anonymize', 'ccpa_anonymize_data'); function ccpa_anonymize_data($email) { // do something here }

If the data subject has a user account, the user will be deleted on the same action at priority 100. This means you can still access it if you set the priority to 10, for example.

Note that if the Delete Action is set to “notify”, then this action is triggered when the admin deletes the data subject, not when the data subject clicks on “delete everything” button.

Read about what exactly happens when a data subject is deleted.

You can register a type of consent via code like this:

Calling ccpa('consent') returns the ConsentManager object. The register function accepts 4 parameters: $slug, $title, $description and $visible. The last one controls whether or not the registered consent should be visible to the data subject on the Privacy Tools page. It defaults to true.

When something happens, for example, a visitor submits a form, you can set a consent like this:

When a visitor withdraws their consent to something, the following action is triggered:

You can set the $validation parameter to false if there’s a condition that disallows the user from withdrawing consent. Make sure you return it either way.

We’ll update this shortly!

Privacy Tools Page

There are two Privacy Tools pages. First, there’s the public facing page on your website’s frontend which can be accessed by authenticating via email. Second, if the data subject has a user account, there’s the Privacy Tools page under Users (or Your Profile) menu item. Both require separate handling, unfortunately. The front-end Privacy Tools page is put together with hooks using the following action:

To add something between the consent table and the data export buttons on the Privacy Tools page:

The existing content is hooked in there in PrivacyToolsPageController:

To remove something, you can fetch the PrivacyToolsPageController object and remove the action like this:

If you wish to add something to the Dashboard Privacy Tools page, you can use the following action:

Overriding templates

You can override each and every template used in this plugin. The mechanism is exactly the same as in WooCommerce and many other major plugins. Just create a folder called ‘ccpa-framework’ inside your theme and place your custom templates inside that folder, using the same folder structure as you can see inside the plugin’s ‘views’ folder. For example, if you wanted to override the email that is sent when a data subject identifies themselves, in your theme folder you would create the following folders and file:

When the View class searches for a view, it first looks into child theme, then parent theme and finally in the plugin.

Do Not Sell My Information

Display The Form

To display the form so users can request that their information not be sold input the shortcode below beneath the privacy tools shortcode without the spaces.