1

I need to set options of a specific plugin at the parent site of a network and use those settings globally to override each site, unless set to false.

Neither get_option() or get_site_option() does the task. They just return values relative to the current site. All the solutions I have encountered are methods to use database query with $wpdb->get_results()but I figure the mighty WP must have a built-in method to do this task.

Example use

  • Plugin setting to display ad banner set to true at parent site
  • The plugin is available across the network to insert banners but cannot be disabled because the condition only accepts the parent value unless set to false

code scenario (not an actual WP function)

if( get_parent_site_option('adbanners')['show_banners'] == 1 ) {
  showAds();
}else
if( get_site_option('adbanners')['show_banners'] == 1 ) {
  showAds();
}else{
  // ads disabled on this current site
}

Is there a WP function to do this without the direct DB query method?

1
  • I'm not sure what you mean by the parent site of a network.
    – Pat J
    Sep 2 at 2:30
1

I found the function to achieve the goal - get_blog_option($blogId, $optionKey)

https://codex.wordpress.org/WPMU_Functions/get_blog_option

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.