Perform action on WPMU blog deletion

Hi guys 🙂 I know there is the wpmu_new_blog action hook which enables us to perform an action when a new WPMU blog is created. Is there something similar to this which enables us to perform an action when a WPMU blog is deleted? Something which looks like this:

add_action('blog_deletion_hook', 'function_to_perform')

3 s
3

Yes, inside /wp-admin/includes/ms.php there is the action hook delete_blog.

This test prevents a blog deletion:

add_action( 'delete_blog', 'prevent_blog_delete_wpse_82961', 10, 2 );

/**
* @param int $blog_id Blog ID
* @param bool $drop True if blog's table should be dropped. Default is false.
*/
function prevent_blog_delete_wpse_82961( $blog_id, $drop ) 
{
    wp_die( 'aborting delete_blog' );
}

Leave a Comment