Synchronize Plugin Settings Across Multisite?

This plugin seems to be defunct: http://wordpress.org/support/plugin/yd-wpmu-sitewide-options

I'm looking for SOME WAY to keep certain plugin settings synchronized across the network.

Help?

  • Gabe

    Hello. I'm sure there are a couple of ways to do this, but here's how I've handled it in the past.

    First, use WPMU's template plugin (https://premium.wpmudev.org/project/new-blog-template/) or something similar (i.e. Blog Copier, Replicator, etc.) to create blogs with the default settings (including plugins) you want.

    Next add a custom.php (name is irrelevant) in your mu-plugins folder than removes the menu hooks for the appropriate users so they can't edit them. I'll usually add a conditional statement to still let Super Admins make edits.

    Here's an example of one I wrote to remove the Akismet and Limit Login Attempts menus, including a conditional statement:

    <?php
    /*
      Plugin Name: Whatever
      Plugin URI: http://whatever.com
      Description: Custom settings blah blah blah
      Author: Whoever
      Version: 1.0
     */
    
    // Hide Akismet stats and Limit Login Attempts from non superadmins
    function remove_submenus() {
      if (!current_user_can('update_core')) {
        $page = remove_submenu_page( 'index.php', 'akismet-stats-display' );
        $page = remove_submenu_page( 'options-general.php', 'limit-login-attempts' );
      }
    }
    add_action( 'admin_menu', 'remove_submenus', 999 );
    ?>

    You can change it to fit any plugin you have, you just need to do some digging to figure out the right function. Depending on how the plugin is built, there could be other variations like using admin_init instead of admin_menu or using unset($submenu['XXX'][XXX]); instead of $page = remove_submenu_page( 'XXX', 'XXX' );. Because it depends on the way the plugin was built, it's hard to find a one-size fits all solution.

    You can also probably just hard-code the settings for each plugin in the plugin files or make them un-editable, but I found this much faster. If you think about it, it'd likely be hard to find something that fits every edge case and every weird configuration for every plugin out there, so you'd probably have to do some custom editing anyway. I'm sure there's also a way to set it in the DB, but I've found this much quicker, more flexible and better for future plugin updates.

  • Fullworks

    Gabe gave a good answer, although the new blog template only has the options at time the template was created, so if you want to later tweak the options across the board then as well as removing the settings pages you will need to add a few lines to hard code teh options, a little bit of detective work in teh plugins settings page code should reveal which update_option() you need to set.

    As aecnu says it is worth experimenting and looking into the code as many plugins have hidden features that make them work in MU sites. For instance, with the plugin WP_SMTP_MAIL if you set 'defines' in wp_config.php it automatically turns of teh settings page and applies the defined values multi-site wide

  • dschulzjackson

    Awesome! This is great! I didn't realize you could hardcode settings into a plugin. Here's the codex' function ref for anyone interested: http://codex.wordpress.org/Function_Reference/update_option

    I'm planning on using Adminimize to hide the stuff from users. It's pretty feature rich and just requires a checkbox (rather than code) for each plugin. But if that doesn't work I'll use the code that Gabe set forth.

    Thanks, all! A robust and helpful response.

    Regarding Gabe's suggestion not to hardcode settings, I'll relay that the multisite I'm going for is so insanely uniform and customization-minimal that I think hardcoding settings will work fine, and if I find myself wanting to make exceptions, I can just add some conditionals based on blog/site ID. Also it is important to me to be able to tweak/update settings for the entire site over time, so for that I think hardcoding is necessary.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.