Multisite Network: How to change permalink structure programmatically on new blogs

With a “mu-plugins”, the solution is…

add_action( 'wpmu_new_blog', function( $blog_id ){

switch_to_blog( $blog_id );
global $wp_rewrite;
$wp_rewrite->set_permalink_structure('/%postname%/');
$wp_rewrite->flush_rules();
restore_current_blog();

}, 10 );