147 | | |
148 | | $userids = $wpdb->get_col("SELECT ID FROM $wpdb->users;"); |
149 | | |
150 | | foreach($userids as $userid) { |
| 147 | |
| 148 | // |
| 149 | // Paging and Search by Mark Jaquith, June 6th, 2006 |
| 150 | // |
| 151 | |
| 152 | $users_per_page = 50; |
| 153 | |
| 154 | $page = (int) $_GET['userspage']; |
| 155 | if ( !$page ) |
| 156 | $page = 1; |
| 157 | |
| 158 | $starton = ($page - 1) * $users_per_page; |
| 159 | |
| 160 | $limit = 'LIMIT ' . $starton . ',' . $users_per_page; |
| 161 | |
| 162 | $search_term = $_GET['usersearch']; |
| 163 | if ( $search_term ) { |
| 164 | $search = array(); |
| 165 | $search_sql = 'AND ('; |
| 166 | foreach ( array('user_login', 'user_nicename', 'user_email', 'user_url', 'display_name') as $col ) |
| 167 | $searches[] = $col . " LIKE '%$search_term%'"; |
| 168 | $search_sql .= implode(' OR ', $searches); |
| 169 | $search_sql .= ')'; |
| 170 | } |
| 171 | |
| 172 | if ( !$search_term && $page == 1 && $wpdb->get_var("SELECT COUNT(ID) FROM $wpdb->users") > $users_per_page ) |
| 173 | $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); |
| 174 | |
| 175 | $from_where = "FROM $wpdb->users WHERE 1=1 $search_sql"; |
| 176 | $userids = $wpdb->get_col('SELECT ID ' . $from_where . $limit); |
| 177 | |
| 178 | if ( $userids ) { |
| 179 | $total_users_for_this_query = $wpdb->get_var('SELECT COUNT(ID) ' . $from_where); // no limit |
| 180 | } else { |
| 181 | $errors[] = __('No matching users were found!'); |
| 182 | } |
| 183 | |
| 184 | // Now for the paging |
| 185 | if ( $total_users_for_this_query > $users_per_page ) { // have to page the results |
| 186 | $prev_page = ( $page > 1) ? true : false; |
| 187 | $next_page = ( ($page * $users_per_page) < $total_users_for_this_query ) ? true : false; |
| 188 | $paging_text = ''; |
| 189 | if ( $prev_page ) |
| 190 | $paging_text .= '<p class="alignleft"><a href="' . add_query_arg('userspage', $page - 1) . '">« Previous Page</a></p>'; |
| 191 | if ( $next_page ) |
| 192 | $paging_text .= '<p class="alignright"><a href="' . add_query_arg('userspage', $page + 1) . '">Next Page »</a></p>'; |
| 193 | if ( $prev_page || $next_page ) |
| 194 | $paging_text .= '<br style="clear:both" />'; |
| 195 | } |
| 196 | |
| 197 | // DONE WITH PAGING AND SEARCH |
| 198 | |
| 199 | foreach( (array) $userids as $userid) { |
206 | | <h2><?php _e('User List by Role'); ?></h2> |
207 | | <table cellpadding="3" cellspacing="3" width="100%"> |
| 272 | <?php if ( $search_term ) : ?> |
| 273 | <h2><?php printf(__('Users Matching "%s" by Role'), $search_term); ?></h2> |
| 274 | <h3><?php printf(__('Results %s - %s of %s shown below'), $starton + 1, min($starton + $users_per_page, $total_users_for_this_query), $total_users_for_this_query); ?></h3> |
| 275 | <div class="user-paging-text"><?php echo $paging_text; ?></div> |
| 276 | <?php else : ?> |
| 277 | <h2><?php _e('User List by Role'); ?></h2> |
| 278 | <?php if ( $paging_text ) : ?> |
| 279 | <div class="user-paging-text"><?php echo $paging_text; ?></p></div> |
| 280 | <?php endif; ?> |
| 281 | <?php endif; ?> |
| 282 | <table cellpadding="3" cellspacing="3" width="100%"> |