Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

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.

share|improve this answer
    
Wow, thank you very, very much for this smart solution! It also works with the Breadcrumb NavXT plugin! The option name is bcn_options. –  user1706680 Oct 31 '12 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 '12 at 13:45

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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