8 */ |
8 */ |
9 |
9 |
10 /** Load WordPress Administration Bootstrap */ |
10 /** Load WordPress Administration Bootstrap */ |
11 require_once( dirname( __FILE__ ) . '/admin.php' ); |
11 require_once( dirname( __FILE__ ) . '/admin.php' ); |
12 |
12 |
13 if ( ! is_multisite() ) |
|
14 wp_die( __( 'Multisite support is not enabled.' ) ); |
|
15 |
|
16 if ( ! current_user_can( 'manage_network_users' ) ) |
13 if ( ! current_user_can( 'manage_network_users' ) ) |
17 wp_die( __( 'You do not have permission to access this page.' ), 403 ); |
14 wp_die( __( 'Sorry, you are not allowed to access this page.' ), 403 ); |
18 |
|
19 function confirm_delete_users( $users ) { |
|
20 $current_user = wp_get_current_user(); |
|
21 if ( ! is_array( $users ) || empty( $users ) ) { |
|
22 return false; |
|
23 } |
|
24 ?> |
|
25 <h2><?php esc_html_e( 'Users' ); ?></h2> |
|
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 |
|
33 <form action="users.php?action=dodelete" method="post"> |
|
34 <input type="hidden" name="dodelete" /> |
|
35 <?php |
|
36 wp_nonce_field( 'ms-users-delete' ); |
|
37 $site_admins = get_super_admins(); |
|
38 $admin_out = '<option value="' . esc_attr( $current_user->ID ) . '">' . $current_user->user_login . '</option>'; ?> |
|
39 <table class="form-table"> |
|
40 <?php foreach ( ( $allusers = (array) $_POST['allusers'] ) as $user_id ) { |
|
41 if ( $user_id != '' && $user_id != '0' ) { |
|
42 $delete_user = get_userdata( $user_id ); |
|
43 |
|
44 if ( ! current_user_can( 'delete_user', $delete_user->ID ) ) { |
|
45 wp_die( sprintf( __( 'Warning! User %s cannot be deleted.' ), $delete_user->user_login ) ); |
|
46 } |
|
47 |
|
48 if ( in_array( $delete_user->user_login, $site_admins ) ) { |
|
49 wp_die( sprintf( __( 'Warning! User cannot be deleted. The user %s is a network administrator.' ), '<em>' . $delete_user->user_login . '</em>' ) ); |
|
50 } |
|
51 ?> |
|
52 <tr> |
|
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 ) ) { |
|
59 ?> |
|
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> |
|
65 <?php |
|
66 foreach ( (array) $blogs as $key => $details ) { |
|
67 $blog_users = get_users( array( 'blog_id' => $details->userblog_id, 'fields' => array( 'ID', 'user_login' ) ) ); |
|
68 if ( is_array( $blog_users ) && !empty( $blog_users ) ) { |
|
69 $user_site = "<a href='" . esc_url( get_home_url( $details->userblog_id ) ) . "'>{$details->blogname}</a>"; |
|
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'>"; |
|
72 $user_list = ''; |
|
73 foreach ( $blog_users as $user ) { |
|
74 if ( ! in_array( $user->ID, $allusers ) ) { |
|
75 $user_list .= "<option value='{$user->ID}'>{$user->user_login}</option>"; |
|
76 } |
|
77 } |
|
78 if ( '' == $user_list ) { |
|
79 $user_list = $admin_out; |
|
80 } |
|
81 $user_dropdown .= $user_list; |
|
82 $user_dropdown .= "</select>\n"; |
|
83 ?> |
|
84 <ul style="list-style:none;"> |
|
85 <li><?php printf( __( 'Site: %s' ), $user_site ); ?></li> |
|
86 <li><label><input type="radio" id="delete_option0" name="delete[<?php echo $details->userblog_id . '][' . $delete_user->ID ?>]" value="delete" checked="checked" /> |
|
87 <?php _e( 'Delete all content.' ); ?></label></li> |
|
88 <li><label><input type="radio" id="delete_option1" name="delete[<?php echo $details->userblog_id . '][' . $delete_user->ID ?>]" value="reassign" /> |
|
89 <?php echo __( 'Attribute all content to:' ) . "</label>\n" . $user_dropdown; ?></li> |
|
90 </ul> |
|
91 <?php |
|
92 } |
|
93 } |
|
94 echo "</fieldset></td></tr>"; |
|
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 |
|
101 } |
|
102 } |
|
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 |
|
116 submit_button( __('Confirm Deletion'), 'delete' ); |
|
117 ?> |
|
118 </form> |
|
119 <?php |
|
120 return true; |
|
121 } |
|
122 |
15 |
123 if ( isset( $_GET['action'] ) ) { |
16 if ( isset( $_GET['action'] ) ) { |
124 /** This action is documented in wp-admin/network/edit.php */ |
17 /** This action is documented in wp-admin/network/edit.php */ |
125 do_action( 'wpmuadminedit' ); |
18 do_action( 'wpmuadminedit' ); |
126 |
19 |
127 switch ( $_GET['action'] ) { |
20 switch ( $_GET['action'] ) { |
128 case 'deleteuser': |
21 case 'deleteuser': |
129 if ( ! current_user_can( 'manage_network_users' ) ) |
22 if ( ! current_user_can( 'manage_network_users' ) ) |
130 wp_die( __( 'You do not have permission to access this page.' ), 403 ); |
23 wp_die( __( 'Sorry, you are not allowed to access this page.' ), 403 ); |
131 |
24 |
132 check_admin_referer( 'deleteuser' ); |
25 check_admin_referer( 'deleteuser' ); |
133 |
26 |
134 $id = intval( $_GET['id'] ); |
27 $id = intval( $_GET['id'] ); |
135 if ( $id != '0' && $id != '1' ) { |
28 if ( $id != '0' && $id != '1' ) { |
159 foreach ( (array) $_POST['allusers'] as $user_id ) { |
52 foreach ( (array) $_POST['allusers'] as $user_id ) { |
160 if ( !empty( $user_id ) ) { |
53 if ( !empty( $user_id ) ) { |
161 switch ( $doaction ) { |
54 switch ( $doaction ) { |
162 case 'delete': |
55 case 'delete': |
163 if ( ! current_user_can( 'delete_users' ) ) |
56 if ( ! current_user_can( 'delete_users' ) ) |
164 wp_die( __( 'You do not have permission to access this page.' ), 403 ); |
57 wp_die( __( 'Sorry, you are not allowed to access this page.' ), 403 ); |
165 $title = __( 'Users' ); |
58 $title = __( 'Users' ); |
166 $parent_file = 'users.php'; |
59 $parent_file = 'users.php'; |
167 require_once( ABSPATH . 'wp-admin/admin-header.php' ); |
60 require_once( ABSPATH . 'wp-admin/admin-header.php' ); |
168 echo '<div class="wrap">'; |
61 echo '<div class="wrap">'; |
169 confirm_delete_users( $_POST['allusers'] ); |
62 confirm_delete_users( $_POST['allusers'] ); |
177 wp_die( sprintf( __( 'Warning! User cannot be modified. The user %s is a network administrator.' ), esc_html( $user->user_login ) ) ); |
70 wp_die( sprintf( __( 'Warning! User cannot be modified. The user %s is a network administrator.' ), esc_html( $user->user_login ) ) ); |
178 |
71 |
179 $userfunction = 'all_spam'; |
72 $userfunction = 'all_spam'; |
180 $blogs = get_blogs_of_user( $user_id, true ); |
73 $blogs = get_blogs_of_user( $user_id, true ); |
181 foreach ( (array) $blogs as $details ) { |
74 foreach ( (array) $blogs as $details ) { |
182 if ( $details->userblog_id != $current_site->blog_id ) // main blog not a spam ! |
75 if ( $details->userblog_id != get_network()->site_id ) // main blog not a spam ! |
183 update_blog_status( $details->userblog_id, 'spam', '1' ); |
76 update_blog_status( $details->userblog_id, 'spam', '1' ); |
184 } |
77 } |
185 update_user_status( $user_id, 'spam', '1' ); |
78 update_user_status( $user_id, 'spam', '1' ); |
186 break; |
79 break; |
187 |
80 |
263 'title' => __('Overview'), |
167 'title' => __('Overview'), |
264 'content' => |
168 'content' => |
265 '<p>' . __('This table shows all users across the network and the sites to which they are assigned.') . '</p>' . |
169 '<p>' . __('This table shows all users across the network and the sites to which they are assigned.') . '</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>' . |
170 '<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>' . |
267 '<p>' . __('You can also go to the user’s profile page by clicking on the individual username.') . '</p>' . |
171 '<p>' . __('You can also go to the user’s profile page by clicking on the individual username.') . '</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>' . |
172 '<p>' . __( 'You can sort the table by clicking on any of the table headings and switch between list and excerpt views by using the icons above the users list.' ) . '</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>' . |
173 '<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>' . |
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>' |
174 '<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>' |
271 ) ); |
175 ) ); |
272 |
176 |
273 get_current_screen()->set_help_sidebar( |
177 get_current_screen()->set_help_sidebar( |
274 '<p><strong>' . __('For more information:') . '</strong></p>' . |
178 '<p><strong>' . __('For more information:') . '</strong></p>' . |
275 '<p>' . __('<a href="https://codex.wordpress.org/Network_Admin_Users_Screen" target="_blank">Documentation on Network Users</a>') . '</p>' . |
179 '<p>' . __('<a href="https://codex.wordpress.org/Network_Admin_Users_Screen">Documentation on Network Users</a>') . '</p>' . |
276 '<p>' . __('<a href="https://wordpress.org/support/forum/multisite/" target="_blank">Support Forums</a>') . '</p>' |
180 '<p>' . __('<a href="https://wordpress.org/support/forum/multisite/">Support Forums</a>') . '</p>' |
277 ); |
181 ); |
|
182 |
|
183 get_current_screen()->set_screen_reader_content( array( |
|
184 'heading_views' => __( 'Filter users list' ), |
|
185 'heading_pagination' => __( 'Users list navigation' ), |
|
186 'heading_list' => __( 'Users list' ), |
|
187 ) ); |
278 |
188 |
279 require_once( ABSPATH . 'wp-admin/admin-header.php' ); |
189 require_once( ABSPATH . 'wp-admin/admin-header.php' ); |
280 |
190 |
281 if ( isset( $_REQUEST['updated'] ) && $_REQUEST['updated'] == 'true' && ! empty( $_REQUEST['action'] ) ) { |
191 if ( isset( $_REQUEST['updated'] ) && $_REQUEST['updated'] == 'true' && ! empty( $_REQUEST['action'] ) ) { |
282 ?> |
192 ?> |
303 </p></div> |
213 </p></div> |
304 <?php |
214 <?php |
305 } |
215 } |
306 ?> |
216 ?> |
307 <div class="wrap"> |
217 <div class="wrap"> |
308 <h2><?php esc_html_e( 'Users' ); |
218 <h1 class="wp-heading-inline"><?php esc_html_e( 'Users' ); ?></h1> |
|
219 |
|
220 <?php |
309 if ( current_user_can( 'create_users') ) : ?> |
221 if ( current_user_can( 'create_users') ) : ?> |
310 <a href="<?php echo network_admin_url('user-new.php'); ?>" class="add-new-h2"><?php echo esc_html_x( 'Add New', 'user' ); ?></a><?php |
222 <a href="<?php echo network_admin_url('user-new.php'); ?>" class="page-title-action"><?php echo esc_html_x( 'Add New', 'user' ); ?></a><?php |
311 endif; |
223 endif; |
312 |
224 |
313 if ( !empty( $usersearch ) ) |
225 if ( strlen( $usersearch ) ) { |
314 printf( '<span class="subtitle">' . __( 'Search results for “%s”' ) . '</span>', esc_html( $usersearch ) ); |
226 /* translators: %s: search keywords */ |
|
227 printf( '<span class="subtitle">' . __( 'Search results for “%s”' ) . '</span>', esc_html( $usersearch ) ); |
|
228 } |
315 ?> |
229 ?> |
316 </h2> |
230 |
|
231 <hr class="wp-header-end"> |
317 |
232 |
318 <?php $wp_list_table->views(); ?> |
233 <?php $wp_list_table->views(); ?> |
319 |
234 |
320 <form method="get" class="search-form"> |
235 <form method="get" class="search-form"> |
321 <?php $wp_list_table->search_box( __( 'Search Users' ), 'all-user' ); ?> |
236 <?php $wp_list_table->search_box( __( 'Search Users' ), 'all-user' ); ?> |