Is there a hook or a function for multisite blog deactivate or delete?

Is there a way to detect if a blog was deleted, deactivated or archived within a Multisite installation ?

Something that will be the opposite of wpmu_new_blog

Read More

I’ve search google, wasn’t much help.

Searched here found: WPMU Hook for archive or deactivate blog?

This post looks relevant however they did not cover deletion nor was it confirmed working by the ‘op’.

Thanks

Related posts

1 comment

  1. If you look at the top answer of the question you found you can read that the user found the hook wpmu_deactivate_blog on wpseek.com.

    Searching for delete_blog got me here: delete_blog. I think delete_blog is the hook you’re looking for. Try it and maybe you can confirm it yourself.

    From the WP3.0 source:

    delete_blog is an Action hook that’s fired in the wpmu_delete_blog function.

    function wpmu_delete_blog( $blog_id, $drop = false ) {
        global $wpdb;
    
        $switch = false;
        if ( get_current_blog_id() != $blog_id ) {
            $switch = true;
            switch_to_blog( $blog_id );
        }
    
        $blog = get_blog_details( $blog_id );
        /**
         * Fires before a blog is deleted.
         *
         * @since MU
         *
         * @param int  $blog_id The blog ID.
         * @param bool $drop    True if blog's table should be dropped. Default is false.
         */
        do_action( 'delete_blog', $blog_id, $drop );
    

    By the looks of it, the function switches to the right blog before firing the delete_blog action hook.

Comments are closed.