wp_privacy_process_personal_data_erasure_page() WordPress Function
The wp_privacy_process_personal_data_erasure_page() function is responsible for handling requests to delete personal data from a WordPress site. This function is triggered when a user submits a request through the WordPress privacy tools page. This function first checks to see if the user has the required permissions to make this request. If the user does not have the correct permissions, the function will return an error. Next, the function will verify the request by checking the nonce and verifying the user's identity. Once the request has been verified, the function will loop through each piece of personal data that has been requested for deletion. For each piece of data, the function will call the appropriate deletion function. Finally, the function will redirect the user back to the WordPress privacy tools page and display a confirmation message.
wp_privacy_process_personal_data_erasure_page( array $response, int $eraser_index, string $email_address, int $page, int $request_id ) #
Mark erasure requests as completed after processing is finished.
Description
This intercepts the Ajax responses to personal data eraser page requests, and monitors the status of a request. Once all of the processing has finished, the request is marked as completed.
See also
Parameters
- $response
(array)(Required)The response from the personal data eraser for the given page.
- $eraser_index
(int)(Required)The index of the personal data eraser. Begins at 1.
- $email_address
(string)(Required)The email address of the user whose personal data this is.
- $page
(int)(Required)The page of personal data for this eraser. Begins at 1.
- $request_id
(int)(Required)The request ID for this personal data erasure.
Return
(array) The filtered response.
Source
File: wp-admin/includes/privacy-tools.php
function wp_privacy_process_personal_data_erasure_page( $response, $eraser_index, $email_address, $page, $request_id ) { /* * If the eraser response is malformed, don't attempt to consume it; let it * pass through, so that the default Ajax processing will generate a warning * to the user. */ if ( ! is_array( $response ) ) { return $response; } if ( ! array_key_exists( 'done', $response ) ) { return $response; } if ( ! array_key_exists( 'items_removed', $response ) ) { return $response; } if ( ! array_key_exists( 'items_retained', $response ) ) { return $response; } if ( ! array_key_exists( 'messages', $response ) ) { return $response; } // Get the request. $request = wp_get_user_request( $request_id ); if ( ! $request || 'remove_personal_data' !== $request->action_name ) { wp_send_json_error( __( 'Invalid request ID when processing personal data to erase.' ) ); } /** This filter is documented in wp-admin/includes/ajax-actions.php */ $erasers = apply_filters( 'wp_privacy_personal_data_erasers', array() ); $is_last_eraser = count( $erasers ) === $eraser_index; $eraser_done = $response['done']; if ( ! $is_last_eraser || ! $eraser_done ) { return $response; } _wp_privacy_completed_request( $request_id ); /** * Fires immediately after a personal data erasure request has been marked completed. * * @since 4.9.6 * * @param int $request_id The privacy request post ID associated with this request. */ do_action( 'wp_privacy_personal_data_erased', $request_id ); return $response; }
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
4.9.6 | Introduced. |