How do I share plugin settings across WordPress network?

The generic way to do it, is by using the pre_option_{option} https://codex.wordpress.org/Plugin_API/Filter_Reference/pre_option_(option_name) filter to override the “local” settings and use the value being stored in your “main” sub site.

something like

add_filter( 'pre_option_the_plugin_option_name', function () {
  // Code assumes that "blog" 1 is the main one in which the relevant settings are stored.
  if (get_current_blog_id() != 1) {
    return get_blog_option(1, 'the_plugin_option_name');
  }

  return false;
}

Depending on the complexity of the plugin, it might not be enough and you will need additional overrides, but this type of code should be enough for simple cases.

Leave a Comment