Define default settings for new sites on multisite network with mu-plugin

I have set up Wordpress with a multisite network. I have been searching around for hours and can't seem to find much documentation on setting custom defaults for all the new sites that are created on the network.

I am using a theme with a child theme installed.

Firstly I would like the default theme for all new sites created on the network to be my child-theme that is installed and Every new site starts with a basic default static front page.

Could this work or should i add it as a function in mu-plugin:

/** Sets default theme for new sites on network */
define( 'WP_DEFAULT_THEME', 'theme-child');

Secondly, Every new site created I need to give access to all administrators on the network. Allowing them to work on all the sites automatically.

Should I try and create a mu-plugin if so please give some direction, or if there is a different way please advise. I haven't coded much in php. Please advise how this can be done.

Thanks

Topic multisite Wordpress

Category Web


So I figured it out: I added the default theme in wp-config:

// Setting default theme for newly created sites 
define( 'WP_DEFAULT_THEME', 'theme-child' );

for the static front page I added:

# ON SIGNUP OF NEW SITES A NEW PAGE IS CREATED CALLED "Homepage" AND SET AS 
THE STATIC FRONT PAGE

add_action( 'wpmu_new_blog', 'process_extra_field_on_blog_signup', 10, 6 );

function process_extra_field_on_blog_signup( $blog_id, $user_id, $domain, 
$path, $site_id, $meta ) {
switch_to_blog($blog_id);


$new_page_title = 'Homepage'; //page title
$new_page_content = 'TEST'; //content of page goes here
$new_page_template = ''; //page template.

$page_check = get_page_by_title($new_page_title);
$new_page = array(
        'post_type' => 'page', 
        'post_title' => $new_page_title,
        'post_content' => $new_page_content,
        'post_status' => 'publish',
        'post_author' => 1,
);
if(!isset($page_check->ID)){
        $new_page_id = wp_insert_post($new_page);
        if(!empty($new_page_template)){
                update_post_meta($new_page_id, '_wp_page_template', $new_page_template);
        }
}

$homepage = get_page_by_title( 'Homepage' );
if ( $homepage )
{
    update_blog_option( $blog_id, 'page_on_front', $homepage->ID );
    update_blog_option( $blog_id, 'show_on_front', 'page' );
}
restore_current_blog();
}

Now I just need to make all users administrators on newly created sites.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.