'; } elseif ( isset($_POST['wp_http_referer']) ) { $redirect = remove_query_arg(array('wp_http_referer', 'updated', 'delete_count'), urlencode(stripslashes($_POST['wp_http_referer']))); $referer = ''; } else { $redirect = 'users.php'; } switch ($action) { case 'promote': check_admin_referer('bulk-users'); if (empty($_POST['users'])) { header('Location: ' . $redirect); } if ( !current_user_can('edit_users') ) die(__('You can’t edit users.')); $userids = $_POST['users']; $update = 'promote'; foreach($userids as $id) { if ( ! current_user_can('edit_user', $id) ) die(__('You can’t edit that user.')); // The new role of the current user must also have edit_users caps if($id == $current_user->id && !$wp_roles->role_objects[$_POST['new_role']]->has_cap('edit_users')) { $update = 'err_admin_role'; continue; } $user = new WP_User($id); $user->set_role($_POST['new_role']); } header('Location: ' . add_query_arg('update', $update, $redirect)); break; case 'dodelete': check_admin_referer('delete-users'); if ( empty($_POST['users']) ) { header('Location: ' . $redirect); } if ( !current_user_can('delete_users') ) die(__('You can’t delete users.')); $userids = $_POST['users']; $update = 'del'; $delete_count = 0; foreach ( (array) $userids as $id) { if ( ! current_user_can('delete_user', $id) ) die(__('You can’t delete that user.')); if($id == $current_user->id) { $update = 'err_admin_del'; continue; } switch($_POST['delete_option']) { case 'delete': wp_delete_user($id); break; case 'reassign': wp_delete_user($id, $_POST['reassign_user']); break; } ++$delete_count; } $redirect = add_query_arg('delete_count', $delete_count, $redirect); header('Location: ' . add_query_arg('update', $update, $redirect)); break; case 'delete': check_admin_referer('bulk-users'); if ( empty($_POST['users']) ) header('Location: ' . $redirect); if ( !current_user_can('delete_users') ) $errors = new WP_Error('edit_users', __('You can’t delete users.')); $userids = $_POST['users']; include ('admin-header.php'); ?>
get_var("SELECT COUNT(ID) FROM $wpdb->users") > $users_per_page ) $too_many_users = sprintf(__('Because this blog has more than %s users, they cannot all be shown on one page. Use the paging or search functionality in order to find the user you want to edit.'), $users_per_page); $from_where = "FROM $wpdb->users WHERE 1=1 $search_sql"; $userids = $wpdb->get_col('SELECT ID ' . $from_where . $limit); if ( $userids ) $total_users_for_this_query = $wpdb->get_var('SELECT COUNT(ID) ' . $from_where); // no limit else $search_errors = new WP_Error('no_matching_users_found', __('No matching users were found!')); // Now for the paging if ( $total_users_for_this_query > $users_per_page ) { // have to page the results $prev_page = ( $page > 1) ? true : false; $next_page = ( ($page * $users_per_page) < $total_users_for_this_query ) ? true : false; $paging_text = ''; if ( $prev_page ) $paging_text .= ''; if ( $next_page ) $paging_text .= ''; if ( $prev_page || $next_page ) $paging_text .= '