12 |
12 |
13 if ( ! is_multisite() ) |
13 if ( ! is_multisite() ) |
14 wp_die( __( 'Multisite support is not enabled.' ) ); |
14 wp_die( __( 'Multisite support is not enabled.' ) ); |
15 |
15 |
16 if ( ! current_user_can( 'manage_network_users' ) ) |
16 if ( ! current_user_can( 'manage_network_users' ) ) |
17 wp_die( __( 'You do not have permission to access this page.' ) ); |
17 wp_die( __( 'You do not have permission to access this page.' ), 403 ); |
18 |
18 |
19 function confirm_delete_users( $users ) { |
19 function confirm_delete_users( $users ) { |
20 $current_user = wp_get_current_user(); |
20 $current_user = wp_get_current_user(); |
21 if ( !is_array( $users ) ) |
21 if ( ! is_array( $users ) || empty( $users ) ) { |
22 return false; |
22 return false; |
23 |
23 } |
24 screen_icon(); |
|
25 ?> |
24 ?> |
26 <h2><?php esc_html_e( 'Users' ); ?></h2> |
25 <h2><?php esc_html_e( 'Users' ); ?></h2> |
27 <p><?php _e( 'Transfer or delete posts before deleting users.' ); ?></p> |
26 |
|
27 <?php if ( 1 == count( $users ) ) : ?> |
|
28 <p><?php _e( 'You have chosen to delete the user from all networks and sites.' ); ?></p> |
|
29 <?php else : ?> |
|
30 <p><?php _e( 'You have chosen to delete the following users from all networks and sites.' ); ?></p> |
|
31 <?php endif; ?> |
|
32 |
28 <form action="users.php?action=dodelete" method="post"> |
33 <form action="users.php?action=dodelete" method="post"> |
29 <input type="hidden" name="dodelete" /> |
34 <input type="hidden" name="dodelete" /> |
30 <?php |
35 <?php |
31 wp_nonce_field( 'ms-users-delete' ); |
36 wp_nonce_field( 'ms-users-delete' ); |
32 $site_admins = get_super_admins(); |
37 $site_admins = get_super_admins(); |
33 $admin_out = "<option value='$current_user->ID'>$current_user->user_login</option>"; |
38 $admin_out = '<option value="' . esc_attr( $current_user->ID ) . '">' . $current_user->user_login . '</option>'; ?> |
34 |
39 <table class="form-table"> |
35 foreach ( ( $allusers = (array) $_POST['allusers'] ) as $key => $val ) { |
40 <?php foreach ( ( $allusers = (array) $_POST['allusers'] ) as $user_id ) { |
36 if ( $val != '' && $val != '0' ) { |
41 if ( $user_id != '' && $user_id != '0' ) { |
37 $delete_user = get_userdata( $val ); |
42 $delete_user = get_userdata( $user_id ); |
38 |
43 |
39 if ( ! current_user_can( 'delete_user', $delete_user->ID ) ) |
44 if ( ! current_user_can( 'delete_user', $delete_user->ID ) ) { |
40 wp_die( sprintf( __( 'Warning! User %s cannot be deleted.' ), $delete_user->user_login ) ); |
45 wp_die( sprintf( __( 'Warning! User %s cannot be deleted.' ), $delete_user->user_login ) ); |
41 |
46 } |
42 if ( in_array( $delete_user->user_login, $site_admins ) ) |
47 |
43 wp_die( sprintf( __( 'Warning! User cannot be deleted. The user %s is a network administrator.' ), $delete_user->user_login ) ); |
48 if ( in_array( $delete_user->user_login, $site_admins ) ) { |
44 |
49 wp_die( sprintf( __( 'Warning! User cannot be deleted. The user %s is a network administrator.' ), '<em>' . $delete_user->user_login . '</em>' ) ); |
45 echo "<input type='hidden' name='user[]' value='{$val}'/>\n"; |
50 } |
46 $blogs = get_blogs_of_user( $val, true ); |
51 ?> |
47 |
52 <tr> |
48 if ( !empty( $blogs ) ) { |
53 <th scope="row"><?php echo $delete_user->user_login; ?> |
|
54 <?php echo '<input type="hidden" name="user[]" value="' . esc_attr( $user_id ) . '" />' . "\n"; ?> |
|
55 </th> |
|
56 <?php $blogs = get_blogs_of_user( $user_id, true ); |
|
57 |
|
58 if ( ! empty( $blogs ) ) { |
49 ?> |
59 ?> |
50 <br /><fieldset><p><legend><?php printf( __( "What should be done with posts owned by <em>%s</em>?" ), $delete_user->user_login ); ?></legend></p> |
60 <td><fieldset><p><legend><?php printf( |
|
61 /* translators: user login */ |
|
62 __( 'What should be done with content owned by %s?' ), |
|
63 '<em>' . $delete_user->user_login . '</em>' |
|
64 ); ?></legend></p> |
51 <?php |
65 <?php |
52 foreach ( (array) $blogs as $key => $details ) { |
66 foreach ( (array) $blogs as $key => $details ) { |
53 $blog_users = get_users( array( 'blog_id' => $details->userblog_id ) ); |
67 $blog_users = get_users( array( 'blog_id' => $details->userblog_id, 'fields' => array( 'ID', 'user_login' ) ) ); |
54 if ( is_array( $blog_users ) && !empty( $blog_users ) ) { |
68 if ( is_array( $blog_users ) && !empty( $blog_users ) ) { |
55 $user_site = "<a href='" . esc_url( get_home_url( $details->userblog_id ) ) . "'>{$details->blogname}</a>"; |
69 $user_site = "<a href='" . esc_url( get_home_url( $details->userblog_id ) ) . "'>{$details->blogname}</a>"; |
56 $user_dropdown = "<select name='blog[$val][{$key}]'>"; |
70 $user_dropdown = '<label for="reassign_user" class="screen-reader-text">' . __( 'Select a user' ) . '</label>'; |
|
71 $user_dropdown .= "<select name='blog[$user_id][$key]' id='reassign_user'>"; |
57 $user_list = ''; |
72 $user_list = ''; |
58 foreach ( $blog_users as $user ) { |
73 foreach ( $blog_users as $user ) { |
59 if ( ! in_array( $user->ID, $allusers ) ) |
74 if ( ! in_array( $user->ID, $allusers ) ) { |
60 $user_list .= "<option value='{$user->ID}'>{$user->user_login}</option>"; |
75 $user_list .= "<option value='{$user->ID}'>{$user->user_login}</option>"; |
|
76 } |
61 } |
77 } |
62 if ( '' == $user_list ) |
78 if ( '' == $user_list ) { |
63 $user_list = $admin_out; |
79 $user_list = $admin_out; |
|
80 } |
64 $user_dropdown .= $user_list; |
81 $user_dropdown .= $user_list; |
65 $user_dropdown .= "</select>\n"; |
82 $user_dropdown .= "</select>\n"; |
66 ?> |
83 ?> |
67 <ul style="list-style:none;"> |
84 <ul style="list-style:none;"> |
68 <li><?php printf( __( 'Site: %s' ), $user_site ); ?></li> |
85 <li><?php printf( __( 'Site: %s' ), $user_site ); ?></li> |
69 <li><label><input type="radio" id="delete_option0" name="delete[<?php echo $details->userblog_id . '][' . $delete_user->ID ?>]" value="delete" checked="checked" /> |
86 <li><label><input type="radio" id="delete_option0" name="delete[<?php echo $details->userblog_id . '][' . $delete_user->ID ?>]" value="delete" checked="checked" /> |
70 <?php _e( 'Delete all posts.' ); ?></label></li> |
87 <?php _e( 'Delete all content.' ); ?></label></li> |
71 <li><label><input type="radio" id="delete_option1" name="delete[<?php echo $details->userblog_id . '][' . $delete_user->ID ?>]" value="reassign" /> |
88 <li><label><input type="radio" id="delete_option1" name="delete[<?php echo $details->userblog_id . '][' . $delete_user->ID ?>]" value="reassign" /> |
72 <?php echo __( 'Attribute all posts to:' ) . '</label>' . $user_dropdown; ?></li> |
89 <?php echo __( 'Attribute all content to:' ) . "</label>\n" . $user_dropdown; ?></li> |
73 </ul> |
90 </ul> |
74 <?php |
91 <?php |
75 } |
92 } |
76 } |
93 } |
77 echo "</fieldset>"; |
94 echo "</fieldset></td></tr>"; |
78 } |
95 } else { |
|
96 ?> |
|
97 <td><fieldset><p><legend><?php _e( 'User has no sites or content and will be deleted.' ); ?></legend></p> |
|
98 <?php } ?> |
|
99 </tr> |
|
100 <?php |
79 } |
101 } |
80 } |
102 } |
81 |
103 |
|
104 ?> |
|
105 </table> |
|
106 <?php |
|
107 /** This action is documented in wp-admin/users.php */ |
|
108 do_action( 'delete_user_form', $current_user ); |
|
109 |
|
110 if ( 1 == count( $users ) ) : ?> |
|
111 <p><?php _e( 'Once you hit “Confirm Deletion”, the user will be permanently removed.' ); ?></p> |
|
112 <?php else : ?> |
|
113 <p><?php _e( 'Once you hit “Confirm Deletion”, these users will be permanently removed.' ); ?></p> |
|
114 <?php endif; |
|
115 |
82 submit_button( __('Confirm Deletion'), 'delete' ); |
116 submit_button( __('Confirm Deletion'), 'delete' ); |
83 ?> |
117 ?> |
84 </form> |
118 </form> |
85 <?php |
119 <?php |
86 return true; |
120 return true; |
87 } |
121 } |
88 |
122 |
89 if ( isset( $_GET['action'] ) ) { |
123 if ( isset( $_GET['action'] ) ) { |
90 do_action( 'wpmuadminedit' , '' ); |
124 /** This action is documented in wp-admin/network/edit.php */ |
|
125 do_action( 'wpmuadminedit' ); |
91 |
126 |
92 switch ( $_GET['action'] ) { |
127 switch ( $_GET['action'] ) { |
93 case 'deleteuser': |
128 case 'deleteuser': |
94 if ( ! current_user_can( 'manage_network_users' ) ) |
129 if ( ! current_user_can( 'manage_network_users' ) ) |
95 wp_die( __( 'You do not have permission to access this page.' ) ); |
130 wp_die( __( 'You do not have permission to access this page.' ), 403 ); |
96 |
131 |
97 check_admin_referer( 'deleteuser' ); |
132 check_admin_referer( 'deleteuser' ); |
98 |
133 |
99 $id = intval( $_GET['id'] ); |
134 $id = intval( $_GET['id'] ); |
100 if ( $id != '0' && $id != '1' ) { |
135 if ( $id != '0' && $id != '1' ) { |
103 $parent_file = 'users.php'; |
138 $parent_file = 'users.php'; |
104 require_once( ABSPATH . 'wp-admin/admin-header.php' ); |
139 require_once( ABSPATH . 'wp-admin/admin-header.php' ); |
105 echo '<div class="wrap">'; |
140 echo '<div class="wrap">'; |
106 confirm_delete_users( $_POST['allusers'] ); |
141 confirm_delete_users( $_POST['allusers'] ); |
107 echo '</div>'; |
142 echo '</div>'; |
108 require_once( ABSPATH . 'wp-admin/admin-footer.php' ); |
143 require_once( ABSPATH . 'wp-admin/admin-footer.php' ); |
109 } else { |
144 } else { |
110 wp_redirect( network_admin_url( 'users.php' ) ); |
145 wp_redirect( network_admin_url( 'users.php' ) ); |
111 } |
146 } |
112 exit(); |
147 exit(); |
113 break; |
|
114 |
148 |
115 case 'allusers': |
149 case 'allusers': |
116 if ( !current_user_can( 'manage_network_users' ) ) |
150 if ( !current_user_can( 'manage_network_users' ) ) |
117 wp_die( __( 'You do not have permission to access this page.' ) ); |
151 wp_die( __( 'You do not have permission to access this page.' ), 403 ); |
118 |
152 |
119 if ( ( isset( $_POST['action']) || isset($_POST['action2'] ) ) && isset( $_POST['allusers'] ) ) { |
153 if ( ( isset( $_POST['action']) || isset($_POST['action2'] ) ) && isset( $_POST['allusers'] ) ) { |
120 check_admin_referer( 'bulk-users-network' ); |
154 check_admin_referer( 'bulk-users-network' ); |
121 |
155 |
122 $doaction = $_POST['action'] != -1 ? $_POST['action'] : $_POST['action2']; |
156 $doaction = $_POST['action'] != -1 ? $_POST['action'] : $_POST['action2']; |
123 $userfunction = ''; |
157 $userfunction = ''; |
124 |
158 |
125 foreach ( (array) $_POST['allusers'] as $key => $val ) { |
159 foreach ( (array) $_POST['allusers'] as $user_id ) { |
126 if ( !empty( $val ) ) { |
160 if ( !empty( $user_id ) ) { |
127 switch ( $doaction ) { |
161 switch ( $doaction ) { |
128 case 'delete': |
162 case 'delete': |
129 if ( ! current_user_can( 'delete_users' ) ) |
163 if ( ! current_user_can( 'delete_users' ) ) |
130 wp_die( __( 'You do not have permission to access this page.' ) ); |
164 wp_die( __( 'You do not have permission to access this page.' ), 403 ); |
131 $title = __( 'Users' ); |
165 $title = __( 'Users' ); |
132 $parent_file = 'users.php'; |
166 $parent_file = 'users.php'; |
133 require_once( ABSPATH . 'wp-admin/admin-header.php' ); |
167 require_once( ABSPATH . 'wp-admin/admin-header.php' ); |
134 echo '<div class="wrap">'; |
168 echo '<div class="wrap">'; |
135 confirm_delete_users( $_POST['allusers'] ); |
169 confirm_delete_users( $_POST['allusers'] ); |
136 echo '</div>'; |
170 echo '</div>'; |
137 require_once( ABSPATH . 'wp-admin/admin-footer.php' ); |
171 require_once( ABSPATH . 'wp-admin/admin-footer.php' ); |
138 exit(); |
172 exit(); |
139 break; |
|
140 |
173 |
141 case 'spam': |
174 case 'spam': |
142 $user = get_userdata( $val ); |
175 $user = get_userdata( $user_id ); |
143 if ( is_super_admin( $user->ID ) ) |
176 if ( is_super_admin( $user->ID ) ) |
144 wp_die( sprintf( __( 'Warning! User cannot be modified. The user %s is a network administrator.' ), esc_html( $user->user_login ) ) ); |
177 wp_die( sprintf( __( 'Warning! User cannot be modified. The user %s is a network administrator.' ), esc_html( $user->user_login ) ) ); |
145 |
178 |
146 $userfunction = 'all_spam'; |
179 $userfunction = 'all_spam'; |
147 $blogs = get_blogs_of_user( $val, true ); |
180 $blogs = get_blogs_of_user( $user_id, true ); |
148 foreach ( (array) $blogs as $key => $details ) { |
181 foreach ( (array) $blogs as $details ) { |
149 if ( $details->userblog_id != $current_site->blog_id ) // main blog not a spam ! |
182 if ( $details->userblog_id != $current_site->blog_id ) // main blog not a spam ! |
150 update_blog_status( $details->userblog_id, 'spam', '1' ); |
183 update_blog_status( $details->userblog_id, 'spam', '1' ); |
151 } |
184 } |
152 update_user_status( $val, 'spam', '1' ); |
185 update_user_status( $user_id, 'spam', '1' ); |
153 break; |
186 break; |
154 |
187 |
155 case 'notspam': |
188 case 'notspam': |
156 $userfunction = 'all_notspam'; |
189 $userfunction = 'all_notspam'; |
157 $blogs = get_blogs_of_user( $val, true ); |
190 $blogs = get_blogs_of_user( $user_id, true ); |
158 foreach ( (array) $blogs as $key => $details ) |
191 foreach ( (array) $blogs as $details ) |
159 update_blog_status( $details->userblog_id, 'spam', '0' ); |
192 update_blog_status( $details->userblog_id, 'spam', '0' ); |
160 |
193 |
161 update_user_status( $val, 'spam', '0' ); |
194 update_user_status( $user_id, 'spam', '0' ); |
162 break; |
195 break; |
163 } |
196 } |
164 } |
197 } |
165 } |
198 } |
166 |
199 |
223 exit; |
254 exit; |
224 } |
255 } |
225 $title = __( 'Users' ); |
256 $title = __( 'Users' ); |
226 $parent_file = 'users.php'; |
257 $parent_file = 'users.php'; |
227 |
258 |
228 add_screen_option( 'per_page', array('label' => _x( 'Users', 'users per page (screen options)' )) ); |
259 add_screen_option( 'per_page' ); |
229 |
260 |
230 get_current_screen()->add_help_tab( array( |
261 get_current_screen()->add_help_tab( array( |
231 'id' => 'overview', |
262 'id' => 'overview', |
232 'title' => __('Overview'), |
263 'title' => __('Overview'), |
233 'content' => |
264 'content' => |
234 '<p>' . __('This table shows all users across the network and the sites to which they are assigned.') . '</p>' . |
265 '<p>' . __('This table shows all users across the network and the sites to which they are assigned.') . '</p>' . |
235 '<p>' . __('Hover over any user on the list to make the edit links appear. The Edit link on the left will take you to his or her Edit User profile page; the Edit link on the right by any site name goes to an Edit Site screen for that site.') . '</p>' . |
266 '<p>' . __('Hover over any user on the list to make the edit links appear. The Edit link on the left will take you to their Edit User profile page; the Edit link on the right by any site name goes to an Edit Site screen for that site.') . '</p>' . |
236 '<p>' . __('You can also go to the user’s profile page by clicking on the individual username.') . '</p>' . |
267 '<p>' . __('You can also go to the user’s profile page by clicking on the individual username.') . '</p>' . |
237 '<p>' . __('You can sort the table by clicking on any of the bold headings and switch between list and excerpt views by using the icons in the upper right.') . '</p>' . |
268 '<p>' . __('You can sort the table by clicking on any of the bold headings and switch between list and excerpt views by using the icons in the upper right.') . '</p>' . |
238 '<p>' . __('The bulk action will permanently delete selected users, or mark/unmark those selected as spam. Spam users will have posts removed and will be unable to sign up again with the same email addresses.') . '</p>' . |
269 '<p>' . __('The bulk action will permanently delete selected users, or mark/unmark those selected as spam. Spam users will have posts removed and will be unable to sign up again with the same email addresses.') . '</p>' . |
239 '<p>' . __('You can make an existing user an additional super admin by going to the Edit User profile page and checking the box to grant that privilege.') . '</p>' |
270 '<p>' . __('You can make an existing user an additional super admin by going to the Edit User profile page and checking the box to grant that privilege.') . '</p>' |
240 ) ); |
271 ) ); |
241 |
272 |
242 get_current_screen()->set_help_sidebar( |
273 get_current_screen()->set_help_sidebar( |
243 '<p><strong>' . __('For more information:') . '</strong></p>' . |
274 '<p><strong>' . __('For more information:') . '</strong></p>' . |
244 '<p>' . __('<a href="http://codex.wordpress.org/Network_Admin_Users_Screen" target="_blank">Documentation on Network Users</a>') . '</p>' . |
275 '<p>' . __('<a href="https://codex.wordpress.org/Network_Admin_Users_Screen" target="_blank">Documentation on Network Users</a>') . '</p>' . |
245 '<p>' . __('<a href="http://wordpress.org/support/forum/multisite/" target="_blank">Support Forums</a>') . '</p>' |
276 '<p>' . __('<a href="https://wordpress.org/support/forum/multisite/" target="_blank">Support Forums</a>') . '</p>' |
246 ); |
277 ); |
247 |
278 |
248 require_once( ABSPATH . 'wp-admin/admin-header.php' ); |
279 require_once( ABSPATH . 'wp-admin/admin-header.php' ); |
249 |
280 |
250 if ( isset( $_REQUEST['updated'] ) && $_REQUEST['updated'] == 'true' && ! empty( $_REQUEST['action'] ) ) { |
281 if ( isset( $_REQUEST['updated'] ) && $_REQUEST['updated'] == 'true' && ! empty( $_REQUEST['action'] ) ) { |
251 ?> |
282 ?> |
252 <div id="message" class="updated"><p> |
283 <div id="message" class="updated notice is-dismissible"><p> |
253 <?php |
284 <?php |
254 switch ( $_REQUEST['action'] ) { |
285 switch ( $_REQUEST['action'] ) { |
255 case 'delete': |
286 case 'delete': |
256 _e( 'User deleted.' ); |
287 _e( 'User deleted.' ); |
257 break; |
288 break; |