Adding sitewide plugin option fields to Network Admin?
I’m working on a plugin, and part of it involves setting an option value that applies to all sites in a WordPress network. I know about the add_site_option and get_site_option functions that let you save the value into the wp_sitemeta table, but what I can’t figure out is how to place the fields in the appropriate place in the WordPress backend, and how to intercept the saving of sitewide values in order to insert the add_site_option call when that happens.
For the first problem (adding the fields), I would normally use the Settings API, specifically register_setting and add_settings_field, to whitelist the new option and then insert a field for it into the appropriate options page. But I can’t find information anywhere on whether you can use add_settings_field to add a field to the Settings page in the new Network Admin section of the backend, if there’s an alternative function that does what it does for Network Admin pages, or if you just have to inject the HTML manually. (You can do it manually by writing a function that echoes out the field and then connecting that function to the “wpmu_options” action, which gets run at the end of the Settings page in Network Admin. But then you also have to deal with nonces and everything else manually.)
The second problem probably involves finding an action that runs when the user hits “Save” on the Network Admin Settings page, but I’ve been unable to find that yet. Any leads would be greatly appreciated.
So — thoughts? Is there an elegant way to allow management of sitewide options for a plugin through the new Network Admin area? If so, how’s it done?
- The topic ‘Adding sitewide plugin option fields to Network Admin?’ is closed to new replies.