处理结束后标记擦除请求已完成。

原型

wp_privacy_process_personal_data_erasure_page( array $response, int $eraser_index, string $email_address, int $page, int $request_id )

描述

这拦截了Ajax对个人数据橡皮擦页面请求的响应,并监视请求的状态。完成所有处理后,请求将标记为已完成。

参考:

  • wp_privacy_personal_data_erasure_page

参数

$response (array) (Required) 个人数据橡皮擦对给定页面的响应。

$eraser_index (int) (Required) 个人数据橡皮擦的索引。从1开始。

$email_address (string) (Required) 用户个人资料的电子邮件地址。

$page (int) (Required) 此橡皮擦的个人数据页面。从1开始。

$request_id (int) (Required) 此个人数据擦除的请求ID。

返回值

(array)  过滤后的响应。

源文件

路径:wp-admin/includes/user.php

<?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;
	}
	$request = wp_get_user_request_data( $request_id );
	if ( ! $request || 'remove_personal_data' !== $request->action_name ) {
		wp_send_json_error( __( 'Invalid request ID when processing eraser data.' ) );
	}
	/** 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;
}
...
?>

其他

英文文档:https://developer.wordpress.org/reference/functions/wp_privacy_process_personal_data_erasure_page/