{"id":595,"date":"2018-05-24T18:35:49","date_gmt":"2018-05-24T23:35:49","guid":{"rendered":"https:\/\/easydigitaldownloads.com\/development\/?p=595"},"modified":"2021-12-15T15:30:56","modified_gmt":"2021-12-15T21:30:56","slug":"easy-digital-downloads-2-9-2-gdpr-tools","status":"publish","type":"post","link":"https:\/\/easydigitaldownloads.com\/development\/2018\/05\/24\/easy-digital-downloads-2-9-2-gdpr-tools\/","title":{"rendered":"Easy Digital Downloads 2.9.2 GDPR Tools"},"content":{"rendered":"<p>As some of you know, we&#8217;ve been hard at work getting Easy Digital Downloads (and its extensions) ready for the GDPR deadline. Over the last week, all the work we&#8217;ve been doing has culminated into what will be version 2.9.2 of Easy Digital Downloads. With this release, we&#8217;ve added a host of hooks and filters, which allow developers integrating with Easy Digital Downloads to process their data for export and erasure alongside of Easy Digital Downloads, instead of having to write all their own routines to do so.<\/p>\n<p>We&#8217;ve also included some helper functions to make your export and erasure integrations easier to write.<\/p>\n<h3>Export Data<\/h3>\n<h4>Filters<\/h4>\n<p><strong>Filter:<\/strong> <code>edd_privacy_customer_record<\/code><br \/>\n<strong>Code:<\/strong> <\/p>\n<pre>$export_data = apply_filters( 'edd_privacy_customer_record', $export_data, $customer );<\/pre>\n<p>This filter will allow developers to put any custom information into the data export for a customer record. This filter supplies you with the data already chosen for export for the customer, as well as the EDD_Customer object itself. Using this filter should return the <code>$export_data<\/code> array. Items added should be in the following form:<\/p>\n<pre>\r\n$export_data[] = array(\r\n    'name'  => __( 'Name for the data' ),\r\n    'value' => $value,\r\n);\r\n<\/pre>\n<p><strong>Filter:<\/strong> <code>edd_privacy_order_details_item<\/code><br \/>\n<strong>Code:<\/strong> <\/p>\n<pre>$data_points = apply_filters( 'edd_privacy_order_details_item', $data_points, $payment );<\/pre>\n<p>This filter will allow developers to supply additional information for a specific payment (order) that is being provided to the export. This filter supplies you with the data already chosen for export, as well as the EDD_Payment object. Using this filter should return the <code>$data_points<\/code> array. Items added should be in the following form:<\/p>\n<pre>\r\n$data_points[] = array(\r\n    'name'  => __( 'Name for the data' ),\r\n    'value' => $value,\r\n);\r\n<\/pre>\n<p><strong>Filter:<\/strong> <code>edd_privacy_file_download_log_item<\/code><br \/>\n<strong>Code:<\/strong> <\/p>\n<pre>$data_points = apply_filters( 'edd_privacy_file_download_log_item', $data_points, $log, $log_meta );<\/pre>\n<p>Allows developers to supply additional information for the file download log export. This filter will supply you with the existing data, as well as the download log post object, and all the post meta found for the log, so you do not have to look it up again. Using this filter should return the <code>$data_points<\/code> array. Items added should be in the following form:<\/p>\n<pre>\r\n$data_points[] = array(\r\n    'name'  => __( 'Name for the data' ),\r\n    'value' => $value,\r\n);\r\n<\/pre>\n<p><strong>Filter:<\/strong> <code>edd_privacy_api_access_log_item<\/code><br \/>\n<strong>Code:<\/strong> <\/p>\n<pre>$data_points = apply_filters( 'edd_privacy_api_access_log_item', $data_points, $log );<\/pre>\n<p>Allows developers to supply additional information for the API access log export. This filter will supply you with the existing data, as well as the API access log post object. Using this filter should return the <code>$data_points<\/code> array. Items added should be in the following form:<\/p>\n<pre>\r\n$data_points[] = array(\r\n    'name'  => __( 'Name for the data' ),\r\n    'value' => $value,\r\n);\r\n<\/pre>\n<h3>Erase\/Anonymize Data<\/h3>\n<h4>Helper Functions<\/h4>\n<p><strong>Function:<\/strong> <code>_edd_privacy_get_customer_id_for_email( $email_address )<\/code><br \/>\n<strong>Purpose:<\/strong> Since each registered eraser callback in the WordPress data eraser process is passed the email address, it is possible that a customer may already be modified when your eraser runs. Therefore, early in the process, Easy Digital Downloads finds, and stores the customer id for the email address requesting erasure. By using the <code>_edd_privacy_get_customer_id_for_email<\/code> function, you can rely on our early lookup, so that you can continue to look up by customer id, not the email address, to avoid having any issues due to a customer already having their email address anonymized in a previously registered eraser callback.<\/p>\n<p><strong>Function:<\/strong> <code>_edd_privacy_get_payment_action( EDD_Payment $payment )<\/code><br \/>\n<strong>Purpose:<\/strong> As you process data erasures, it may be necessary for you to look up what type of action is supposed to be performed on an EDD_Payment object. This helper function looks up the actions specified in the <code>Downloads > Settings > Privacy > Export & Erase<\/code> section, and then allows extensions to filter the action based off their own criteria.<\/p>\n<p>The function does have a filter (<code>'edd_privacy_payment_status_action_' . $payment->status<\/code>) which allows the customization on a per-extension basis. An example use case is, normally a completed payment would allowed to be anonymized, but if our Simple Shipping extension is enabled, and the payment has not yet been shipped, we should not allow this payment to be anonymized, as the store owner still needs data from it to be able to correctly ship the item(s) ordered.<\/p>\n<h4>Filters<\/h4>\n<p><strong>Filter:<\/strong> <code>edd_should_anonymize_customer<\/code><br \/>\n<strong>Code:<\/strong><\/p>\n<pre>\r\n$should_anonymize_customer = apply_filters( 'edd_should_anonymize_customer',\r\n    array( \r\n        'should_anonymize' => true,\r\n        'message' => '' ),\r\n    $customer );\r\n<\/pre>\n<p>When a customer requests to be deleted, there may be a business need to not allow this anonymization or deletion. By default Easy Digital Downloads will proceed with its determination if the customer should be processed, but before it does, it allows extensions to tell it if the customer should be processed.<\/p>\n<p>The return of this should be in the following array format:<\/p>\n<pre>\r\narray( \r\n    'should_anonymize' => true, \/\/ If this customer should be anonymized \r\n    'message' => '',            \/\/ If should_anonymize is false, supply a reason\r\n)\r\n<\/pre>\n<p><strong>Filter:<\/strong> <code>edd_should_anonymize_payment<\/code><br \/>\n<strong>Code:<\/strong><\/p>\n<pre>\r\n$should_anonymize_payment = apply_filters( 'edd_should_anonymize_payment', \r\n    array( \r\n        'should_anonymize' => true,\r\n        'message' => '' \r\n    ),\r\n    $payment\r\n);\r\n<\/pre>\n<p>During the erasure process, all payments associated with the customer found are processed to take one of three actions (and the string used to reference them in the code) :<\/p>\n<ul>\n<li>No Action &#8211; (none)<\/li>\n<li>Anonymization &#8211; (anonymize)<\/li>\n<li>Deletion &#8211; (delete)<\/li>\n<\/ul>\n<p>The status of the payment typically determines what action should be taken, and the action for a specific payment status can be modified by store owners in <code>Downloads > Settings > Privacy > Export & Erase<\/code><\/p>\n<p>There are, however, times where an extension may need to override that action, which is where this filter becomes useful. With this filter, developers can inspect a payment and determine if it is allowed to be anonymized based off their own criteria, and tell the eraser to leave it alone, by performing no action on it.<\/p>\n<p>The return of this should be in the following array format:<\/p>\n<pre>\r\narray( \r\n    'should_anonymize' => true, \/\/ If this customer should be anonymized \r\n    'message' => '',            \/\/ If should_anonymize is false, supply a reason\r\n)\r\n<\/pre>\n<h4>Actions<\/h4>\n<p><strong>Action:<\/strong> <code>edd_anonymize_customer<\/code><br \/>\n<strong>Code:<\/strong><\/p>\n<pre>do_action( 'edd_anonymize_customer', $customer );<\/pre>\n<p>When a customer requests to be deleted, Easy Digital Downloads first runs anonymization on them (and later determines if they can be fully deleted). After the anonymization is completed, this action is run, supplying the EDD_Customer object, so developers can take any further action necessary. It passes in the EDD_Customer object of the customer being processed.<\/p>\n<p><strong>Action:<\/strong> <code>edd_anonymize_payment<\/code><br \/>\n<strong>Code:<\/strong><\/p>\n<pre>do_action( 'edd_anonymize_payment', $payment );<\/pre>\n<p>After Easy Digital Downloads has processed the payment for anonymization, but before saving the payment, this action is run, passing in the EDD_Payment object, allowing developers to make further changes. It passes in the EDD_Payment object of the payment being processed.<\/p>\n<p><strong>Action:<\/strong> <code>edd_anonymize_file_download_log<\/code><br \/>\n<strong>Code:<\/strong><\/p>\n<pre>do_action( 'edd_anonymize_file_download_log', $log );<\/pre>\n<p>In the event that a payment is required to be anonymized (not deleted), the file download logs associated with it are anonymized as well. This action will allow further anonymization of a file download log, if necessary. It passes in the WP_Post object of the $log.<\/p>\n<p><strong>Action:<\/strong> <code>edd_delete_api_access_log<\/code><br \/>\n<strong>Code:<\/strong><\/p>\n<pre>do_action( 'edd_delete_api_access_log', $log );<\/pre>\n<p>When a user requests deletion, if they have any API Access logs in the database, this action will allow you to take further action after they are deleted. It passes in the WP_Post object of the $log.<\/p>\n<h3>Conclusion<\/h3>\n<p>So that&#8217;s a wrap on our updates to Easy Digital Downloads core for the GDPR release. As with all software projects and legal regulations, this will evolve as the ecosystem deems necessary. All of these hooks, filters, and functions can be found in the <code>includes\/privacy-functions.php<\/code> of Easy Digital Downloads version 2.9.2 or later.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>As some of you know, we&#8217;ve been hard at work getting Easy Digital Downloads (and its extensions) ready for the GDPR deadline. Over the last week, all the work we&#8217;ve been doing has culminated into&#8230;<\/p>\n<p class=\"continue-reading\"><a class=\"more-link\" href=\"https:\/\/easydigitaldownloads.com\/development\/2018\/05\/24\/easy-digital-downloads-2-9-2-gdpr-tools\/\">Continue reading &rarr;<\/a><\/p>\n","protected":false},"author":650,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[4],"tags":[18],"class_list":["post-595","post","type-post","status-publish","format-standard","hentry","category-core","tag-gdpr"],"_links":{"self":[{"href":"https:\/\/easydigitaldownloads.com\/development\/wp-json\/wp\/v2\/posts\/595","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/easydigitaldownloads.com\/development\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/easydigitaldownloads.com\/development\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/easydigitaldownloads.com\/development\/wp-json\/wp\/v2\/users\/650"}],"replies":[{"embeddable":true,"href":"https:\/\/easydigitaldownloads.com\/development\/wp-json\/wp\/v2\/comments?post=595"}],"version-history":[{"count":10,"href":"https:\/\/easydigitaldownloads.com\/development\/wp-json\/wp\/v2\/posts\/595\/revisions"}],"predecessor-version":[{"id":611,"href":"https:\/\/easydigitaldownloads.com\/development\/wp-json\/wp\/v2\/posts\/595\/revisions\/611"}],"wp:attachment":[{"href":"https:\/\/easydigitaldownloads.com\/development\/wp-json\/wp\/v2\/media?parent=595"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/easydigitaldownloads.com\/development\/wp-json\/wp\/v2\/categories?post=595"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/easydigitaldownloads.com\/development\/wp-json\/wp\/v2\/tags?post=595"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}