TransWikia.com

Is there a way to add a function that will get run after a blog is created?

WordPress Development Asked on December 26, 2021

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:

EXAMPLE!!!
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 );

}

One Answer

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 ); 

Answered by Madra David on December 26, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP