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 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.

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.

share|improve this question

1 Answer 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.

share|improve this answer
    
that looks like exactly what I need. Is there any documentation on how to save the network settings? Normal options are registered using register_setting - is there something similar for site options as well, or do we just roll our own settings persistance? What I mean is that normal settings are just saved by registering them and then creating a form with action="options.php" and WordPress magically saves them. –  Jason Oct 18 '11 at 20:45
    
You're confusing "options" with "settings." Settings work with the WordPress Settings API and let you build per-site options pages without rolling your own solution. Options are key-value pairs stored in the database either per-site or network-wide depending on whether you use add_option() or add_site_option(). –  EAMann Oct 18 '11 at 21:06
    
i greatly appreciate your help. If I choose to use site_options to store my network-wide values, then do I need to roll my own form and form processing functions to allow the site admin to save those values? since "settings" has a good api for creating forms, I did not want to roll my own code for "options" if there was a similar api or mechanism for doing so. –  Jason Oct 18 '11 at 21:31
    
sorry to be annoying with the follow-up questions, it just is difficult to find if there is an official way to handle network-wide settings for plugins. If there isn't then I'll just happily go about rolling my own, but I wanted to be sure first I wasn't missing anything. thanks again. –  Jason Oct 18 '11 at 21:42
    
There isn't a built-in way to handle network-wide settings for plugins that I know of in 3.2.1 or even 3.3. –  EAMann Oct 18 '11 at 22:39

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.