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')
Yes, inside
/wp-admin/includes/ms.php
there is the action hookdelete_blog
.This test prevents a blog deletion:
WordPress use since version 5.1 a new hook.
do_action( 'wp_delete_site', $old_site );
The var
$old_site
is the deleted site object.If you need a hook before the blog will delete, use the hook below.
You should use a hook from this two options because the hook
delete_blog
is deprecated.FYI this is now deprecated. I haven’t found a substitute yet, unfortunately 🙁
https://developer.wordpress.org/reference/hooks/delete_blog/