|
83 | 83 | if ( is_super_admin( $user->ID ) ) { |
84 | 84 | wp_die( |
85 | 85 | sprintf( |
86 | | - /* translators: %s: User login. */ |
| 86 | + /* translators: %s: User login. */ |
87 | 87 | __( 'Warning! User cannot be modified. The user %s is a network administrator.' ), |
88 | 88 | esc_html( $user->user_login ) |
89 | | - ) |
| 89 | + ), |
| 90 | + 403 |
90 | 91 | ); |
91 | 92 | } |
92 | 93 |
|
93 | 94 | $userfunction = 'all_spam'; |
94 | | - $blogs = get_blogs_of_user( $user_id, true ); |
95 | 95 |
|
96 | | - foreach ( (array) $blogs as $details ) { |
97 | | - if ( ! is_main_site( $details->userblog_id ) ) { // Main site is not a spam! |
98 | | - update_blog_status( $details->userblog_id, 'spam', '1' ); |
| 96 | + /** |
| 97 | + * Filters whether to propagate the blog status when a user is marked as spam. |
| 98 | + * |
| 99 | + * @since 6.9.0 |
| 100 | + * |
| 101 | + * @param bool $propagate Whether to propagate the blog status. Default false. |
| 102 | + * @param int $user_id User ID. |
| 103 | + */ |
| 104 | + if ( apply_filters( 'propagate_network_user_spam_to_blogs', false, $user_id ) ) { |
| 105 | + foreach ( get_blogs_of_user( $user_id, true ) as $details ) { |
| 106 | + if ( ! is_main_site( $details->userblog_id ) ) { // Main site is not a spam! |
| 107 | + update_blog_status( $details->userblog_id, 'spam', '1' ); |
| 108 | + } |
99 | 109 | } |
100 | 110 | } |
101 | 111 |
|
|
107 | 117 |
|
108 | 118 | case 'notspam': |
109 | 119 | $user = get_userdata( $user_id ); |
| 120 | + if ( is_super_admin( $user->ID ) ) { |
| 121 | + wp_die( |
| 122 | + sprintf( |
| 123 | + /* translators: %s: User login. */ |
| 124 | + __( 'Warning! User cannot be modified. The user %s is a network administrator.' ), |
| 125 | + esc_html( $user->user_login ) |
| 126 | + ), |
| 127 | + 403 |
| 128 | + ); |
| 129 | + } |
110 | 130 |
|
111 | 131 | $userfunction = 'all_notspam'; |
112 | 132 | $blogs = get_blogs_of_user( $user_id, true ); |
113 | 133 |
|
114 | | - foreach ( (array) $blogs as $details ) { |
115 | | - update_blog_status( $details->userblog_id, 'spam', '0' ); |
| 134 | + /** This filter is documented in wp-admin/network/users.php */ |
| 135 | + if ( apply_filters( 'propagate_network_user_spam_to_blogs', false, $user_id ) ) { |
| 136 | + foreach ( get_blogs_of_user( $user_id, true ) as $details ) { |
| 137 | + if ( ! is_main_site( $details->userblog_id ) && get_current_network_id() === $details->site_id ) { // Main site is never a spam and part of the current network. |
| 138 | + update_blog_status( $details->userblog_id, 'spam', '0' ); |
| 139 | + } |
| 140 | + } |
116 | 141 | } |
117 | 142 |
|
118 | 143 | $user_data = $user->to_array(); |
|
0 commit comments