Stop Site Admins From Deleting Their Own Site
Removes Tools > Delete Site from subsite dashboards and blocks the screen, so only super admins can delete sites from Network Admin.
Opens WPIDE on
Code
if ( ! is_multisite() ) {
return;
}
add_action( 'admin_menu', function () {
if ( ! is_super_admin() ) {
remove_submenu_page( 'tools.php', 'ms-delete-site.php' );
}
}, 999 );
add_action( 'load-ms-delete-site.php', function () {
if ( ! is_super_admin() ) {
wp_die( esc_html__( 'Please contact the network administrator to delete this site.' ), 403 );
}
} );
Notes
""
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.