3 * Multisite users administration panel.
6 * @subpackage Multisite
10 /** Load WordPress Administration Bootstrap */
11 require_once( dirname( __FILE__ ) . '/admin.php' );
13 if ( ! is_multisite() )
14 wp_die( __( 'Multisite support is not enabled.' ) );
16 if ( ! current_user_can( 'manage_network_users' ) )
17 wp_die( __( 'You do not have permission to access this page.' ), 403 );
19 if ( isset( $_GET['action'] ) ) {
20 /** This action is documented in wp-admin/network/edit.php */
21 do_action( 'wpmuadminedit' );
23 switch ( $_GET['action'] ) {
25 if ( ! current_user_can( 'manage_network_users' ) )
26 wp_die( __( 'You do not have permission to access this page.' ), 403 );
28 check_admin_referer( 'deleteuser' );
30 $id = intval( $_GET['id'] );
31 if ( $id != '0' && $id != '1' ) {
32 $_POST['allusers'] = array( $id ); // confirm_delete_users() can only handle with arrays
33 $title = __( 'Users' );
34 $parent_file = 'users.php';
35 require_once( ABSPATH . 'wp-admin/admin-header.php' );
36 echo '<div class="wrap">';
37 confirm_delete_users( $_POST['allusers'] );
39 require_once( ABSPATH . 'wp-admin/admin-footer.php' );
41 wp_redirect( network_admin_url( 'users.php' ) );
46 if ( !current_user_can( 'manage_network_users' ) )
47 wp_die( __( 'You do not have permission to access this page.' ), 403 );
49 if ( ( isset( $_POST['action']) || isset($_POST['action2'] ) ) && isset( $_POST['allusers'] ) ) {
50 check_admin_referer( 'bulk-users-network' );
52 $doaction = $_POST['action'] != -1 ? $_POST['action'] : $_POST['action2'];
55 foreach ( (array) $_POST['allusers'] as $user_id ) {
56 if ( !empty( $user_id ) ) {
57 switch ( $doaction ) {
59 if ( ! current_user_can( 'delete_users' ) )
60 wp_die( __( 'You do not have permission to access this page.' ), 403 );
61 $title = __( 'Users' );
62 $parent_file = 'users.php';
63 require_once( ABSPATH . 'wp-admin/admin-header.php' );
64 echo '<div class="wrap">';
65 confirm_delete_users( $_POST['allusers'] );
67 require_once( ABSPATH . 'wp-admin/admin-footer.php' );
71 $user = get_userdata( $user_id );
72 if ( is_super_admin( $user->ID ) )
73 wp_die( sprintf( __( 'Warning! User cannot be modified. The user %s is a network administrator.' ), esc_html( $user->user_login ) ) );
75 $userfunction = 'all_spam';
76 $blogs = get_blogs_of_user( $user_id, true );
77 foreach ( (array) $blogs as $details ) {
78 if ( $details->userblog_id != $current_site->blog_id ) // main blog not a spam !
79 update_blog_status( $details->userblog_id, 'spam', '1' );
81 update_user_status( $user_id, 'spam', '1' );
85 $userfunction = 'all_notspam';
86 $blogs = get_blogs_of_user( $user_id, true );
87 foreach ( (array) $blogs as $details )
88 update_blog_status( $details->userblog_id, 'spam', '0' );
90 update_user_status( $user_id, 'spam', '0' );
96 wp_safe_redirect( add_query_arg( array( 'updated' => 'true', 'action' => $userfunction ), wp_get_referer() ) );
98 $location = network_admin_url( 'users.php' );
100 if ( ! empty( $_REQUEST['paged'] ) )
101 $location = add_query_arg( 'paged', (int) $_REQUEST['paged'], $location );
102 wp_redirect( $location );
107 check_admin_referer( 'ms-users-delete' );
108 if ( ! ( current_user_can( 'manage_network_users' ) && current_user_can( 'delete_users' ) ) )
109 wp_die( __( 'You do not have permission to access this page.' ), 403 );
111 if ( ! empty( $_POST['blog'] ) && is_array( $_POST['blog'] ) ) {
112 foreach ( $_POST['blog'] as $id => $users ) {
113 foreach ( $users as $blogid => $user_id ) {
114 if ( ! current_user_can( 'delete_user', $id ) )
117 if ( ! empty( $_POST['delete'] ) && 'reassign' == $_POST['delete'][$blogid][$id] )
118 remove_user_from_blog( $id, $blogid, $user_id );
120 remove_user_from_blog( $id, $blogid );
125 if ( is_array( $_POST['user'] ) && ! empty( $_POST['user'] ) )
126 foreach ( $_POST['user'] as $id ) {
127 if ( ! current_user_can( 'delete_user', $id ) )
129 wpmu_delete_user( $id );
134 $deletefunction = 'delete';
136 $deletefunction = 'all_delete';
138 wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => $deletefunction ), network_admin_url( 'users.php' ) ) );
143 $wp_list_table = _get_list_table('WP_MS_Users_List_Table');
144 $pagenum = $wp_list_table->get_pagenum();
145 $wp_list_table->prepare_items();
146 $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
148 if ( $pagenum > $total_pages && $total_pages > 0 ) {
149 wp_redirect( add_query_arg( 'paged', $total_pages ) );
152 $title = __( 'Users' );
153 $parent_file = 'users.php';
155 add_screen_option( 'per_page' );
157 get_current_screen()->add_help_tab( array(
159 'title' => __('Overview'),
161 '<p>' . __('This table shows all users across the network and the sites to which they are assigned.') . '</p>' .
162 '<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>' .
163 '<p>' . __('You can also go to the user’s profile page by clicking on the individual username.') . '</p>' .
164 '<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>' .
165 '<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>' .
166 '<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>'
169 get_current_screen()->set_help_sidebar(
170 '<p><strong>' . __('For more information:') . '</strong></p>' .
171 '<p>' . __('<a href="https://codex.wordpress.org/Network_Admin_Users_Screen" target="_blank">Documentation on Network Users</a>') . '</p>' .
172 '<p>' . __('<a href="https://wordpress.org/support/forum/multisite/" target="_blank">Support Forums</a>') . '</p>'
175 get_current_screen()->set_screen_reader_content( array(
176 'heading_views' => __( 'Filter users list' ),
177 'heading_pagination' => __( 'Users list navigation' ),
178 'heading_list' => __( 'Users list' ),
181 require_once( ABSPATH . 'wp-admin/admin-header.php' );
183 if ( isset( $_REQUEST['updated'] ) && $_REQUEST['updated'] == 'true' && ! empty( $_REQUEST['action'] ) ) {
185 <div id="message" class="updated notice is-dismissible"><p>
187 switch ( $_REQUEST['action'] ) {
189 _e( 'User deleted.' );
192 _e( 'Users marked as spam.' );
195 _e( 'Users removed from spam.' );
198 _e( 'Users deleted.' );
210 <h1><?php esc_html_e( 'Users' );
211 if ( current_user_can( 'create_users') ) : ?>
212 <a href="<?php echo network_admin_url('user-new.php'); ?>" class="page-title-action"><?php echo esc_html_x( 'Add New', 'user' ); ?></a><?php
215 if ( !empty( $usersearch ) )
216 printf( '<span class="subtitle">' . __( 'Search results for “%s”' ) . '</span>', esc_html( $usersearch ) );
220 <?php $wp_list_table->views(); ?>
222 <form method="get" class="search-form">
223 <?php $wp_list_table->search_box( __( 'Search Users' ), 'all-user' ); ?>
226 <form id="form-user-list" action="users.php?action=allusers" method="post">
227 <?php $wp_list_table->display(); ?>
231 <?php require_once( ABSPATH . 'wp-admin/admin-footer.php' ); ?>