The MU forums have moved to WordPress.org

How do I run my plugin function when a blog is deleted? (4 posts)

  1. moronometer
    Member
    Posted 14 years ago #

    I am new to WPMU so forgive a n00b question.

    I have figured out how to run my function when creating a blog:

    add_action( 'wpmu_new_blog', 'my_function', 10, 2 );
    function my_function($blog_id, $user_id) {
         // do cool stuff when a blog is created
    }

    I have this in a plugin file in my mu-plugins folder, and it works properly.

    How do I hook to run when a blog is deleted?

    I tried this:

    add_action( 'wpmu_delete_blog', 'my_function2', 10, 2 );
    function my_function2($blog_id) {
         mail(myself, 'hi', $blog_id.' was just deleted!');
    }

    But it didn't work. =(

    Please advise.

    Thank in advance!

  2. moronometer
    Member
    Posted 14 years ago #

    Is there anybody out there?

  3. dsader
    Member
    Posted 14 years ago #

    <?php
    add_action( 'delete_blog', 'my_function2', 10, 2 );
    function my_function2($blog_id) {
    //	$email = 'yourname@mail.tld';
    	$email =  stripslashes( get_site_option('admin_email') );
    	$subject = $blog_id.' was just deleted!';
    	$message = $blog_id.' was just deleted!';
         mail($email, $subject , $message);
    }
    ?>
  4. moronometer
    Member
    Posted 14 years ago #

    Thank you so much!

About this Topic

  • Started 14 years ago by moronometer
  • Latest reply from moronometer