3 * Multisite users administration panel.
6 * @subpackage Multisite
10 require_once( './admin.php' );
12 if ( !is_multisite() )
13 wp_die( __( 'Multisite support is not enabled.' ) );
15 if ( ! current_user_can( 'manage_network_users' ) )
16 wp_die( __( 'You do not have permission to access this page.' ) );
18 $title = __( 'Users' );
19 $parent_file = 'ms-admin.php';
21 add_contextual_help($current_screen,
22 '<p>' . __('This table shows all users across the network and the sites to which they are assigned.') . '</p>' .
23 '<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>' .
24 '<p>' . __('You can also go to the user’s profile page by clicking on the individual username.') . '</p>' .
25 '<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>' .
26 '<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>' .
27 '<p>' . __('Add User will add that person to this table and send them an email.') . '</p>' .
28 '<p>' . __('Users who are signed up to the network without a site are added as subscribers to the main or primary dashboard site, giving them profile pages to manage their accounts. These users will only see Dashboard and My Sites in the main navigation until a site is created for them.') . '</p>' .
29 '<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>' .
30 '<p><strong>' . __('For more information:') . '</strong></p>' .
31 '<p>' . __('<a href="http://codex.wordpress.org/Super_Admin_Users_SubPanel" target="_blank">Network Users Documentation</a>') . '</p>' .
32 '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
35 wp_enqueue_script( 'admin-forms' );
37 require_once( './admin-header.php' );
39 if ( isset( $_GET['updated'] ) && $_GET['updated'] == 'true' && ! empty( $_GET['action'] ) ) {
41 <div id="message" class="updated"><p>
43 switch ( $_GET['action'] ) {
45 _e( 'User deleted.' );
48 _e( 'Users marked as spam.' );
51 _e( 'Users removed from spam.' );
54 _e( 'Users deleted.' );
65 $pagenum = isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 0;
66 if ( empty( $pagenum ) )
69 $per_page = (int) get_user_option( 'ms_users_per_page' );
70 if ( empty( $per_page ) || $per_page < 1 )
73 $per_page = apply_filters( 'ms_users_per_page', $per_page );
75 $s = isset( $_GET['s'] ) ? stripslashes( trim( $_GET[ 's' ] ) ) : '';
76 $like_s = esc_sql( like_escape( $s ) );
78 $query = "SELECT * FROM {$wpdb->users}";
80 if ( !empty( $like_s ) ) {
81 $query .= " WHERE user_login LIKE '%$like_s%' OR user_email LIKE '%$like_s%'";
84 $order_by = isset( $_GET['sortby'] ) ? $_GET['sortby'] : 'id';
85 if ( $order_by == 'email' ) {
86 $query .= ' ORDER BY user_email ';
87 } elseif ( $order_by == 'login' ) {
88 $query .= ' ORDER BY user_login ';
89 } elseif ( $order_by == 'name' ) {
90 $query .= ' ORDER BY display_name ';
91 } elseif ( $order_by == 'registered' ) {
92 $query .= ' ORDER BY user_registered ';
95 $query .= ' ORDER BY ID ';
98 $order = ( isset( $_GET['order'] ) && 'DESC' == $_GET['order'] ) ? 'DESC' : 'ASC';
101 $total = $wpdb->get_var( str_replace( 'SELECT *', 'SELECT COUNT(ID)', $query ) );
103 $query .= " LIMIT " . intval( ( $pagenum - 1 ) * $per_page) . ", " . intval( $per_page );
105 $user_list = $wpdb->get_results( $query, ARRAY_A );
107 $num_pages = ceil( $total / $per_page );
108 $page_links = paginate_links( array(
109 'base' => add_query_arg( 'paged', '%#%' ),
111 'prev_text' => __( '«' ),
112 'next_text' => __( '»' ),
113 'total' => $num_pages,
114 'current' => $pagenum
117 if ( empty( $_GET['mode'] ) )
120 $mode = esc_attr( $_GET['mode'] );
124 <?php screen_icon(); ?>
125 <h2><?php esc_html_e( 'Users' ); ?>
126 <a href="#form-add-user" class="button add-new-h2"><?php echo esc_html_x( 'Add New' , 'users'); ?></a>
128 if ( isset( $_GET['s'] ) && $_GET['s'] )
129 printf( '<span class="subtitle">' . __( 'Search results for “%s”' ) . '</span>', esc_html( $s ) );
133 <form action="ms-users.php" method="get" class="search-form">
134 <p class="search-box">
135 <input type="text" name="s" value="<?php echo esc_attr( $s ); ?>" class="search-input" id="user-search-input" />
136 <input type="submit" id="post-query-submit" value="<?php esc_attr_e( 'Search Users' ) ?>" class="button" />
140 <form id="form-user-list" action='ms-edit.php?action=allusers' method='post'>
141 <input type="hidden" name="mode" value="<?php echo esc_attr( $mode ); ?>" />
142 <div class="tablenav">
143 <div class="alignleft actions">
144 <select name="action">
145 <option value="-1" selected="selected"><?php _e( 'Bulk Actions' ); ?></option>
146 <option value="delete"><?php _e( 'Delete' ); ?></option>
147 <option value="spam"><?php _ex( 'Mark as Spam', 'user' ); ?></option>
148 <option value="notspam"><?php _ex( 'Not Spam', 'user' ); ?></option>
150 <input type="submit" value="<?php esc_attr_e( 'Apply' ); ?>" name="doaction" id="doaction" class="button-secondary action" />
151 <?php wp_nonce_field( 'bulk-ms-users', '_wpnonce_bulk-ms-users' ); ?>
154 <?php if ( $page_links ) { ?>
155 <div class="tablenav-pages">
156 <?php $page_links_text = sprintf( '<span class="displaying-num">' . __( 'Displaying %s–%s of %s' ) . '</span>%s',
157 number_format_i18n( ( $pagenum - 1 ) * $per_page + 1 ),
158 number_format_i18n( min( $pagenum * $per_page, $total ) ),
159 number_format_i18n( $total ),
161 ); echo $page_links_text; ?>
165 <div class="view-switch">
166 <a href="<?php echo esc_url( add_query_arg( 'mode', 'list', $_SERVER['REQUEST_URI'] ) ) ?>"><img <?php if ( 'list' == $mode ) echo 'class="current"'; ?> id="view-switch-list" src="<?php echo esc_url( includes_url( 'images/blank.gif' ) ); ?>" width="20" height="20" title="<?php _e( 'List View' ) ?>" alt="<?php _e( 'List View' ) ?>" /></a>
167 <a href="<?php echo esc_url( add_query_arg( 'mode', 'excerpt', $_SERVER['REQUEST_URI'] ) ) ?>"><img <?php if ( 'excerpt' == $mode ) echo 'class="current"'; ?> id="view-switch-excerpt" src="<?php echo esc_url( includes_url( 'images/blank.gif' ) ); ?>" width="20" height="20" title="<?php _e( 'Excerpt View' ) ?>" alt="<?php _e( 'Excerpt View' ) ?>" /></a>
170 <div class="clear"></div>
173 // define the columns to display, the syntax is 'internal name' => 'display name'
174 $users_columns = array(
176 'login' => __( 'Username' ),
177 'name' => __( 'Name' ),
178 'email' => __( 'E-mail' ),
179 'registered' => _x( 'Registered', 'user' ),
180 'blogs' => __( 'Sites' )
182 $users_columns = apply_filters( 'wpmu_users_columns', $users_columns );
184 <table class="widefat">
187 <th class="manage-column column-cb check-column" scope="col">
188 <input type="checkbox" />
192 foreach($users_columns as $column_id => $column_display_name) {
193 $column_link = "<a href='";
195 if ( $order_by == $column_id )
196 $order2 = ( $order == 'DESC' ) ? 'ASC' : 'DESC';
198 $column_link .= esc_url( add_query_arg( array( 'order' => $order2, 'paged' => $pagenum, 'sortby' => $column_id ), remove_query_arg( array( 'action', 'updated' ), $_SERVER['REQUEST_URI'] ) ) );
199 $column_link .= "'>{$column_display_name}</a>";
200 $col_url .= '<th scope="col">' . ( $column_id == 'blogs' ? $column_display_name : $column_link ) . '</th>';
207 <th class="manage-column column-cb check-column" scope="col">
208 <input type="checkbox" />
210 <?php echo $col_url; ?>
213 <tbody id="the-user-list" class="list:user">
214 <?php if ( $user_list ) {
216 $super_admins = get_super_admins();
217 foreach ( (array) $user_list as $user ) {
218 $class = ( 'alternate' == $class ) ? '' : 'alternate';
220 $status_list = array( 'spam' => 'site-spammed', 'deleted' => 'site-deleted' );
222 foreach ( $status_list as $status => $col ) {
223 if ( $user[$status] )
228 <tr class="<?php echo $class; ?>">
230 foreach( (array) $users_columns as $column_name=>$column_display_name ) :
231 switch( $column_name ) {
233 <th scope="row" class="check-column">
234 <input type="checkbox" id="blog_<?php echo $user['ID'] ?>" name="allusers[]" value="<?php echo esc_attr( $user['ID'] ) ?>" />
236 <th valign="top" scope="row">
237 <?php echo $user['ID'] ?>
243 $avatar = get_avatar( $user['user_email'], 32 );
244 $edit_link = ( $current_user->ID == $user['ID'] ) ? 'profile.php' : 'user-edit.php?user_id=' . $user['ID'];
246 <td class="username column-username">
247 <?php echo $avatar; ?><strong><a href="<?php echo esc_url( admin_url( $edit_link ) ); ?>" class="edit"><?php echo stripslashes( $user['user_login'] ); ?></a><?php
248 if ( in_array( $user['user_login'], $super_admins ) )
249 echo ' - ' . __( 'Super admin' );
252 <div class="row-actions">
253 <span class="edit"><a href="<?php echo esc_url( admin_url( $edit_link ) ); ?>"><?php _e( 'Edit' ); ?></a></span>
254 <?php if ( ! in_array( $user['user_login'], $super_admins ) ) { ?>
255 | <span class="delete"><a href="<?php echo $delete = esc_url( admin_url( add_query_arg( '_wp_http_referer', urlencode( stripslashes( $_SERVER['REQUEST_URI'] ) ), wp_nonce_url( 'ms-edit.php', 'deleteuser' ) . '&action=deleteuser&id=' . $user['ID'] ) ) ); ?>" class="delete"><?php _e( 'Delete' ); ?></a></span>
263 <td class="name column-name"><?php echo $user['display_name'] ?></td>
268 <td class="email column-email"><a href="mailto:<?php echo $user['user_email'] ?>"><?php echo $user['user_email'] ?></a></td>
273 if ( 'list' == $mode )
276 $date = 'Y/m/d \<\b\r \/\> g:i:s a';
278 <td><?php echo mysql2date( __( $date ), $user['user_registered'] ); ?></td>
283 $blogs = get_blogs_of_user( $user['ID'], true );
287 if ( is_array( $blogs ) ) {
288 foreach ( (array) $blogs as $key => $val ) {
289 $path = ( $val->path == '/' ) ? '' : $val->path;
290 echo '<a href="'. esc_url( admin_url( 'ms-sites.php?action=editblog&id=' . $val->userblog_id ) ) .'">' . str_replace( '.' . $current_site->domain, '', $val->domain . $path ) . '</a>';
291 echo ' <small class="row-actions">';
294 echo '<a href="'. esc_url( admin_url( 'ms-sites.php?action=editblog&id=' . $val->userblog_id ) ) .'">' . __( 'Edit' ) . '</a> | ';
298 if ( get_blog_status( $val->userblog_id, 'spam' ) == 1 )
299 echo 'style="background-color: #faa" ';
300 echo 'href="' . esc_url( get_home_url( $val->userblog_id ) ) . '">' . __( 'View' ) . '</a>';
302 echo '</small><br />';
311 <td><?php do_action( 'manage_users_custom_column', $column_name, $user['ID'] ); ?></td>
323 <td colspan="<?php echo (int) count($users_columns); ?>"><?php _e( 'No users found.' ) ?></td>
331 <div class="tablenav">
334 echo "<div class='tablenav-pages'>$page_links_text</div>";
337 <div class="alignleft actions">
338 <select name="action2">
339 <option value="-1" selected="selected"><?php _e( 'Bulk Actions' ); ?></option>
340 <option value="delete"><?php _e( 'Delete' ); ?></option>
341 <option value="spam"><?php _ex( 'Mark as Spam', 'user' ); ?></option>
342 <option value="notspam"><?php _ex( 'Not Spam', 'user' ); ?></option>
344 <input type="submit" value="<?php esc_attr_e( 'Apply' ); ?>" name="doaction2" id="doaction2" class="button-secondary action" />
353 if ( apply_filters( 'show_adduser_fields', true ) ) :
355 <div class="wrap" id="form-add-user">
356 <h3><?php _e( 'Add User' ) ?></h3>
357 <form action="ms-edit.php?action=adduser" method="post">
358 <table class="form-table">
359 <tr class="form-field form-required">
360 <th scope="row"><?php _e( 'Username' ) ?></th>
361 <td><input type="text" class="regular-text" name="user[username]" /></td>
363 <tr class="form-field form-required">
364 <th scope="row"><?php _e( 'Email' ) ?></th>
365 <td><input type="text" class="regular-text" name="user[email]" /></td>
367 <tr class="form-field">
368 <td colspan="2"><?php _e( 'Username and password will be mailed to the above email address.' ) ?></td>
372 <?php wp_nonce_field( 'add-user', '_wpnonce_add-user' ) ?>
373 <input class="button" type="submit" value="<?php esc_attr_e( 'Add user' ) ?>" /></p>
378 <?php include( './admin-footer.php' ); ?>