Remind Administrators to Publish a Privacy Policy
Shows a notice on the dashboard while no published privacy policy page is selected in Settings > Privacy, with a link to set one up.
Opens WPIDE on
Code
add_action( 'admin_notices', function () {
$screen = get_current_screen();
if ( ! $screen || 'dashboard' !== $screen->id || ! current_user_can( 'manage_privacy_options' ) ) {
return;
}
$page_id = (int) get_option( 'wp_page_for_privacy_policy' );
if ( $page_id && 'publish' === get_post_status( $page_id ) ) {
return;
}
printf(
'<div class="notice notice-warning"><p>%s <a href="%s">%s</a></p></div>',
esc_html( 'Your site has no published privacy policy page.' ),
esc_url( admin_url( 'options-privacy.php' ) ),
esc_html( 'Set one up now' )
);
} );
Notes
The notice disappears as soon as a published page is selected.
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.