diff --git a/src/wp-admin/network/users.php b/src/wp-admin/network/users.php index 29238cd887034..007da802a97d4 100644 --- a/src/wp-admin/network/users.php +++ b/src/wp-admin/network/users.php @@ -103,10 +103,15 @@ */ if ( apply_filters( 'propagate_network_user_spam_to_blogs', false, $user_id ) ) { foreach ( get_blogs_of_user( $user_id, true ) as $details ) { - // Assuming the main site is not a spam. - if ( ! is_main_site( $details->userblog_id ) ) { - update_blog_status( $details->userblog_id, 'spam', '1' ); + // Do not mark the main site as spam, and only affect the current network. + if ( is_main_site( $details->userblog_id ) || get_current_network_id() !== $details->site_id ) { + continue; } + // Only mark sites where the user is the registered site admin. + if ( get_blog_option( $details->userblog_id, 'admin_email' ) !== $user->user_email ) { + continue; + } + update_blog_status( $details->userblog_id, 'spam', '1' ); } } @@ -131,15 +136,19 @@ } $userfunction = 'all_notspam'; - $blogs = get_blogs_of_user( $user_id, true ); /** This filter is documented in wp-admin/network/users.php */ if ( apply_filters( 'propagate_network_user_spam_to_blogs', false, $user_id ) ) { foreach ( get_blogs_of_user( $user_id, true ) as $details ) { - if ( ! is_main_site( $details->userblog_id ) && get_current_network_id() === $details->site_id ) { - // Assuming main site is never a spam and part of the current network. - update_blog_status( $details->userblog_id, 'spam', '0' ); + // Do not unmark the main site as spam, and only affect the current network. + if ( is_main_site( $details->userblog_id ) || get_current_network_id() !== $details->site_id ) { + continue; + } + // Only unmark sites where the user is the registered site admin. + if ( get_blog_option( $details->userblog_id, 'admin_email' ) !== $user->user_email ) { + continue; } + update_blog_status( $details->userblog_id, 'spam', '0' ); } }