Inherit plugin settings to new site in Multisite

Nice Question!

But I’ll leave for the asker and for the reader the task of finding the plugin options name.

This can be used for any plugin/theme that relies in a single/serialized value in the wp_options table. If it’s not a single value, it’s another task…

In this example, I’m using WP-Pagenavi option_name.

wp-pagenavi option name

Action hook found inside the function wpmu_create_blog in the file /wp-includes/ms-functions.php.

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

function wpse_70977_copy_main_site_options( $blog_id, $user_id, $domain, $path, $site_id, $meta )
{
    $mainsite = get_option( 'pagenavi_options' );
    switch_to_blog( $blog_id );
    update_option( 'pagenavi_options', $mainsite );
    restore_current_blog();
}

This code is tested with the plugin being activated on a per site basis, and with the plugin being Network Activated.

Leave a Comment