1

I am managing a multi-site instance of Wp with 300 sites and so I am trying to see if this can be done automatically.

I know individually I can go to each site and change the admin email value in the settings but is there a way to affect all sites? I have tried searching for this and can't seem to find a post discussing this exact topic.

1
  • 1
    I'd guess that's stored in a per-site options table? You could probably either make some dynamic SQL with table name as a parameter that you exec(), or if you can do this over the REST API then you could script something that loops over all the site URLs (that you can probably get from the wp_sites table), or you can also probably script this using wp-cli I'd think, again with one command per-site and looping over sites. Or you could write some PHP to do it and run it from a temporary plugin or button in your dashboard.
    – Rup
    Commented Sep 10, 2020 at 11:02

1 Answer 1

1

Okay so thanks to the suggestion from Rup I got this to work and apply to all my sites locally (will double check this before using on live!)

$blogs = get_sites(['public' => 1, 'orderby' => 'registered', 'order' => 'DESC', 'number' => 1000]);

foreach($blogs as $blog) {
    $bid = $blog->blog_id;
    switch_to_blog($bid);

    update_option( 'admin_email', '[email protected]' );
    update_option( 'new_admin_email', '[email protected]' ); 
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.