I have a multi-site network, and want to secure the /wp-admin/ms-delete-site.php so that it does not execute. We want to manage site deletions from the command line only.

I have added a call to wp_die() at the top for now, but I would prefer to handle this in a plugin, and not make any changes to the WP core files.

What is the best way to implement this in a plugin?

2 Answers 2


Another alternative is to look at the hook map_meta_cap and remove the user's capability to delete_site. If you have a restricted set of users or context when you want to allow delete_site then you can allow the capability.


You're right, editing core is a no-no.

Instead, you can do this.

add_action( 'current_screen', 'wpse242553_no_delete_site_screen' );
function wpse242553_no_delete_site_screen() {
    // Check to see if we're using the CLI client. If so, bail out.
    if ( 'cli' == php_sapi_name() ) {
        // I'm not sure this is strictly necessary.
    if ( 'ms-delete-site' == get_current_screen()->base ) {
        // You can add whatever message you like here,
        // or even use wp_safe_redirect() to go elsewhere.
        wp_die( 'Sorry, we only delete sites from the command line.' );


Put it in a Must Use plugin to have it applied on every site in your network.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.