Can I mass change all admin emails for a multisite instance?

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.

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 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', '<a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="a6c7c2cbcfc8e6c7c2cbcfc888c5c9cb">[email protected]</a>' );
    update_option( 'new_admin_email', '<a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="94f5f0f9fdfad4f5f0f9fdfabaf7fbf9">[email protected]</a>' ); 
}


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x