5

I use the Breadcrumb NavXT plugin for a WP Multisite. I activated the plugin for all sites so I can use it throughout my network.

My problem is that every time I add a new site I have to change the default settings of the plugin, but I’d like WP to use the settings I already customized for the main site because on all future sites they would be the same.

Is there a way to force WP adopting the plugin settings of the main site?

1 Answer 1

5

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.

2
  • Wow, thank you very, very much for this smart solution! It also works with the Breadcrumb NavXT plugin! The option name is bcn_options. Oct 31, 2012 at 12:41
  • Just thought of it: this solution may present issues if the plugin/theme has some setting that points to a specific site table or has some specific site URL. In which case, maybe saving/updating the plugin/theme settings afterwards will correct the issue.
    – brasofilo
    Oct 31, 2012 at 13:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.