Where should I store global data for my multi-site WordPress plugin?

I wrote a plugin for WordPress which has a few user-configurable settings that are stored using WordPress’s suggested method. I know they are saved in the wp_options table, but that is abstracted by the WordPress options API.

Now I’m trying to add a “global override” of the settings that can be configured in the Network Admin section of a multi-site installation. I found the appropriate hooks to design my settings page, however I can’t find any info about where to save the data.

Read More

If I save it using the normal options API, then the settings get saved individually for each site. I’m looking for a place to save them globally for all sites, so the plugin can first look to see if the settings have been globally overridden by the server admin.

I can just write some code to write directly to the wp_options table of one of the sites (for example site #1) or even create my own table. I know how to do all of these things, but I don’t want to do that if there’s a preferred way to write mult-site plugins.

Thanks for any advice.

Related posts

Leave a Reply

1 comment

  1. You’re looking for get_site_option(). From the Codex:

    Retrieve option value based on name of option. In multisite, return network option, blog option otherwise.