Run code when a new blog is created

Run some code when a new blog is created. I'm not sure, but I guess this code has to be in a network-activated or mu-plugins plugin. Maybe having this code enabled in the blog you're using will suffice.

add_action( 'wpmu_new_blog', 'create_new_site' );

function create_new_site( $blog_id ) {
                switch_to_blog( $blogid );
    // do whatever you want to do


Start a new thread

Cancel reply
Markdown. Syntax highlighting with <code lang="php"><?php echo "Hello, world!"; ?></code> etc.