Is there a way to have a function run after a blog is created in WP MU? I think I would need to add a filter or something but I'm not as familiar with the procedure.

Do I set something up like this:

add_filter('new_blog_created', 'my_function');

function my_function() {
    // do something

So far I'm calling wpmu_create_blog() to create a new blog successfully if that helps.

Here is my code which is inside a function:

function create_site() {
    // some code
    $meta = apply_filters( 'add_signup_meta', $meta );

    $result = wpmu_create_blog( $domain, $path, $blog_title, $current_user->ID, $meta, $wpdb->siteid );


1 Answer 1


Have you tried the action 'wpmu_new_blog' .

The docstring for the function 'wpmu_create_blog' says:

  • This function runs when a user self-registers a new site as well
  • as when a Super Admin creates a new site. Hook to 'wpmu_new_blog'
  • for events that should affect all new sites.

wpmu_new_blog is called with the following parameters:

do_action( 'wpmu_new_blog', $blog_id, $user_id, $domain, $path, $site_id, $meta ); 
  • Would I make a filter for "wpmu_new_blog" then? Feb 12, 2014 at 9:54
  • You can simply add an action , for example your function my_function() will be run after the blog is created .add_action( 'wpmu_new_blog', 'my_function' ); Feb 12, 2014 at 9:58
  • Is the "." before "add_action" important? Where do I place this code? BTW I updated my example code. What I mean is do I place it inside of a function before I call "wpmu_new_blog" or outside of the function? Feb 12, 2014 at 10:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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