clean_blog_cache( $site );
// Populate the site's roles.
populate_roles();
$wp_roles =
new WP_Roles();
// Populate metadata for the site.
populate_site_meta( $site->id,
$args['meta'
] );
// Remove all permissions that may exist for the site.
$table_prefix =
$wpdb->
get_blog_prefix();
delete_metadata( 'user', 0,
$table_prefix . 'user_level', null, true
); // Delete all.
delete_metadata( 'user', 0,
$table_prefix . 'capabilities', null, true
); // Delete all.
// Install default site content.
wp_install_defaults( $args['user_id'
] );
// Set the site administrator.
add_user_to_blog( $site->id,
$args['user_id'
], 'administrator'
);
if ( !
user_can( $args['user_id'
], 'manage_network'
) && !
get_user_meta( $args['user_id'
], 'primary_blog', true
) ) { update_user_meta( $args['user_id'
], 'primary_blog',
$site->id
);
}