• Resolved Steve

    (@srg-1)


    Hello!

    I have a plugin that uses the Settings API and adds a menu for its configuration under “Settings” on the left dashboard menu. It adds the page with add_options_page() hooked on admin_menu. Sections are added to the page with add_settings_section(), registered with register_setting(), and fields added with add_settings_field(). Everything is working perfectly on single-site instances.

    What’s the best way to support multisite as well? All configuration for this plugin is global (the configuration must apply to every site and can only be set by network admins on the network-admin dashboard).

    This StackExchange post, although several years old, says that the Settings API does not support global network-level configurations. This means I must use the Options API instead. Is that correct?

    Should I give up the Settings API (even for single-site) and switch to Options API?

    Thank you!

    • This topic was modified 4 years, 7 months ago by Steve. Reason: Improved formatting
Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    Yes use the Options API. Note there are multisite specific functions that correspond to single site functions. Like update_site_option() vs. update_option(). So you always end up with a lot of is_multisite() conditionals to use one or the other.

    The two APIs are not either/or. Settings API allows you to easily build settings forms. Settings which get stored in the global options table. This is a handy feature if it does what you want. If it doesn’t, it’s not that useful. You’re left with building your own options forms, which in some respects is a lot easier than using the Settings API.

    Personally, I like the Settings API for adding settings fields to existing forms. For full pages of input fields I think it’s easier to build my own forms anyway and use the Options API to save anything destined for options tables. Building our own forms lets us save data where ever it makes sense, it does not have to be an options table.

    Thread Starter Steve

    (@srg-1)

    Awesome! Thank you for taking the time to reply. This makes sense to me. I’ll re-implement my plugin using the Options API and creating the forms manually.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Multisite: Settings API vs Options API’ is closed to new replies.