|
91 | 91 | } |
92 | 92 |
|
93 | 93 | $userfunction = 'all_spam'; |
94 | | - $blogs = get_blogs_of_user( $user_id, true ); |
95 | 94 |
|
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' ); |
| 95 | + /** |
| 96 | + * Filters whether the blog status for all of a user's blogs should be updated. |
| 97 | + * |
| 98 | + * @since 6.7 |
| 99 | + * |
| 100 | + * @param bool $update_blog_status Whether to update the blog status. Default true. |
| 101 | + */ |
| 102 | + if ( apply_filters( 'handle_allusers_update_blog_status', true ) ) { |
| 103 | + $blogs = get_blogs_of_user( $user_id, true ); |
| 104 | + |
| 105 | + foreach ( (array) $blogs 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 | + ); |
| 128 | + } |
110 | 129 |
|
111 | 130 | $userfunction = 'all_notspam'; |
112 | | - $blogs = get_blogs_of_user( $user_id, true ); |
113 | 131 |
|
114 | | - foreach ( (array) $blogs as $details ) { |
115 | | - update_blog_status( $details->userblog_id, 'spam', '0' ); |
| 132 | + /** This filter is documented in wp-admin/network/users.php#L95 */ |
| 133 | + if ( apply_filters( 'handle_allusers_blog_status', true ) ) { |
| 134 | + $blogs = get_blogs_of_user( $user_id, true ); |
| 135 | + |
| 136 | + foreach ( (array) $blogs as $details ) { |
| 137 | + if ( ! is_main_site( $details->userblog_id ) ) { // Main site is never a spam! |
| 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