_wp_personal_data_cleanup_requests

函数
_wp_personal_data_cleanup_requests ( No parameters )

_wp_personal_data_cleanup_requests: 这是一个私有函数,用于在数据被导出或删除后,删除指定用户ID的个人数据。它是WordPress 4.9.6中引入的数据隐私和GDPR合规功能的一部分。

在显示列表表之前清理失败和过期的请求。

function _wp_personal_data_cleanup_requests() {
	/** This filter is documented in wp-includes/user.php */
	$expires = (int) apply_filters( 'user_request_key_expiration', DAY_IN_SECONDS );

	$requests_query = new WP_Query(
		array(
			'post_type'      => 'user_request',
			'posts_per_page' => -1,
			'post_status'    => 'request-pending',
			'fields'         => 'ids',
			'date_query'     => array(
				array(
					'column' => 'post_modified_gmt',
					'before' => $expires . ' seconds ago',
				),
			),
		)
	);

	$request_ids = $requests_query->posts;

	foreach ( $request_ids as $request_id ) {
		wp_update_post(
			array(
				'ID'            => $request_id,
				'post_status'   => 'request-failed',
				'post_password' => '',
			)
		);
	}
}

常见问题

FAQs
查看更多 >