Skip to content

Commit 40a95f7

Browse files
committed
Networks and Sites: Only propagate user spam status to admin-owned sites
1 parent bf4c174 commit 40a95f7

1 file changed

Lines changed: 16 additions & 7 deletions

File tree

src/wp-admin/network/users.php

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,15 @@
103103
*/
104104
if ( apply_filters( 'propagate_network_user_spam_to_blogs', false, $user_id ) ) {
105105
foreach ( get_blogs_of_user( $user_id, true ) as $details ) {
106-
// Assuming the main site is not a spam.
107-
if ( ! is_main_site( $details->userblog_id ) ) {
108-
update_blog_status( $details->userblog_id, 'spam', '1' );
106+
// Do not mark the main site as spam, and only affect the current network.
107+
if ( is_main_site( $details->userblog_id ) || get_current_network_id() !== $details->site_id ) {
108+
continue;
109109
}
110+
// Only mark sites where the user is the registered site admin.
111+
if ( get_blog_option( $details->userblog_id, 'admin_email' ) !== $user->user_email ) {
112+
continue;
113+
}
114+
update_blog_status( $details->userblog_id, 'spam', '1' );
110115
}
111116
}
112117

@@ -131,15 +136,19 @@
131136
}
132137

133138
$userfunction = 'all_notspam';
134-
$blogs = get_blogs_of_user( $user_id, true );
135139

136140
/** This filter is documented in wp-admin/network/users.php */
137141
if ( apply_filters( 'propagate_network_user_spam_to_blogs', false, $user_id ) ) {
138142
foreach ( get_blogs_of_user( $user_id, true ) as $details ) {
139-
if ( ! is_main_site( $details->userblog_id ) && get_current_network_id() === $details->site_id ) {
140-
// Assuming main site is never a spam and part of the current network.
141-
update_blog_status( $details->userblog_id, 'spam', '0' );
143+
// Do not unmark the main site as spam, and only affect the current network.
144+
if ( is_main_site( $details->userblog_id ) || get_current_network_id() !== $details->site_id ) {
145+
continue;
146+
}
147+
// Only unmark sites where the user is the registered site admin.
148+
if ( get_blog_option( $details->userblog_id, 'admin_email' ) !== $user->user_email ) {
149+
continue;
142150
}
151+
update_blog_status( $details->userblog_id, 'spam', '0' );
143152
}
144153
}
145154

0 commit comments

Comments
 (0)