I have a multisite instance of WordPress with almost 100 sites. I need to set an option for a network-wide installed plugin but I don’t want to go to each site dashboard to set this option by hand. How could I do ?
The option I want to change is a classic option, not a network-wide one. It comes from a plugin that I did not write. Want I need it to change the value of that classic option for all sites in my network at once.
Excuse me if I’m misunderstanding you, but aren’t the functions add_site_option()
, update_site_option()
and get_site_option()
pretty much, they fall back to single site functions, if not used in a multisite environment, only there for the purpose of having network-wide options.
Update:
Regarding your need to change a single site option for all sites in your network. Get all sites of the network with wp_get_sites()
, which returns an array of arrays. You can use the array to loop through your single sites in your multisite installation. Make use of switch_to_blog()
and restore_current_blog()
while looping against the $blog_ids
. In between the loop after switching and before restoring, use the single site options functions add_option()
, update_option()
and get_option()
as needed.