Warn About Privacy Requests Close to the 30-Day Deadline
Shows a dashboard notice to administrators when a personal data request has been waiting for more than 25 days, since GDPR expects an answer within one month.
Opens WPIDE on
Code
// Warn when a request is older than this many days.
$wpide_request_warn_days = 25;
add_action( 'admin_notices', function () use ( $wpide_request_warn_days ) {
global $wpdb;
if ( ! current_user_can( 'manage_options' ) ) {
return;
}
$late = get_transient( 'wpide_late_privacy_requests' );
if ( false === $late ) {
$late = (int) $wpdb->get_var( $wpdb->prepare(
"SELECT COUNT(*) FROM {$wpdb->posts} WHERE post_type = 'user_request' AND post_status IN ('request-pending','request-confirmed') AND post_date_gmt < %s",
gmdate( 'Y-m-d H:i:s', time() - $wpide_request_warn_days * DAY_IN_SECONDS )
) );
set_transient( 'wpide_late_privacy_requests', $late, HOUR_IN_SECONDS );
}
if ( $late ) {
printf(
'<div class="notice notice-error"><p>%s <a href="%s">Export requests</a> | <a href="%s">Erasure requests</a></p></div>',
esc_html( sprintf( '%d personal data request(s) have been open for more than %d days.', $late, $wpide_request_warn_days ) ),
esc_url( admin_url( 'export-personal-data.php' ) ),
esc_url( admin_url( 'erase-personal-data.php' ) )
);
}
} );
Notes
Change $wpide_request_warn_days to warn earlier; the check is cached for an hour.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.