WordPress.org

Make WordPress Core

Opened 8 years ago

Closed 8 years ago

#2793 closed enhancement (fixed)

User Management: Paging, Search, Bug Fixes

Reported by: markjaquith Owned by: markjaquith
Milestone: 2.1 Priority: normal
Severity: normal Version: 2.1
Component: Administration Keywords: needs-testing has-patch so-many-patches
Focuses: Cc:

Description

Attached patch adds the following:

User Paging

Users page, 50 at a time. If there are more than 50 users, a small notice is shown explaining that all the users can't be shown on one page, and that people will have to use the previous/next navigation or the search, in order to find the user they want.

Wait a second, search?!

User Search

Yes, search. Now, you can search for users based on user_login, user_nicename, user_email, display_name or user_url. Results are paged when over 50, naturally.

thead bug fixed

The first <thead> with the ID/Username/email/etc headers, gets pushed to the TOP of the table in Firefox. So, it looks funky for the first one, but the following ones look fine.

I just switched to using a classed <tr class="thead"> and added .thead to the thead CSS declaration.

"Cannot delete user" error bug fixed

$error = new WP_Error('etc', 'etc');

changed to the correct:

$errors = new WP_Error('etc', 'etc');

Everything is (I think) properly i18n'd. I took proper precautions with regards to casting to int and wp_specialchars() protection of the search term.

Even better, I have this patched for /branches/2.0/ as well as /trunk/

Attachments (15)

users_paging_search_bugfixes_TRUNK.diff (5.0 KB) - added by markjaquith 8 years ago.
Patch for /trunk/
users_paging_search_bugfixes_BRANCHES_2.0.diff (4.3 KB) - added by markjaquith 8 years ago.
patch for /branches/2.0/
create-lots-of-users.php (1.8 KB) - added by markjaquith 8 years ago.
Helper script for /trunk/ --- creates something like 900 users. Place in /wp-admin/ and access via browser.
2793.diff (9.4 KB) - added by davidhouse 8 years ago.
Several additions to Mark's patch; see my comment(s) below.
2793.2.diff (8.6 KB) - added by davidhouse 8 years ago.
Version 2, the old one had a hunk from an older patch.
2793.3.diff (8.9 KB) - added by markjaquith 8 years ago.
i18n fixes, moved the notification box above the search, reworded the link back to "all users"
2793.4.diff (10.4 KB) - added by markjaquith 8 years ago.
Latest and greatest
2793.5.diff (10.4 KB) - added by markjaquith 8 years ago.
Latest and greatest 2
2793.6.diff (22.6 KB) - added by markjaquith 8 years ago.
Latest and greatest 3
2793.7.diff (23.1 KB) - added by markjaquith 8 years ago.
oops, fix user-edit.php submenu
2793.8.diff (25.9 KB) - added by markjaquith 8 years ago.
bigger, better
reorganize_users.php.diff (3.2 KB) - added by markjaquith 8 years ago.
reorganize search, put it all into one wrap
WP_User_Search_class.diff (9.0 KB) - added by markjaquith 8 years ago.
Move user search/paging to a class
alpha.diff (4.3 KB) - added by filosofo 8 years ago.
Adds alphabetizing feature to the paging
users_paging_search_bugfixes_2.0.4.diff (4.3 KB) - added by markjaquith 8 years ago.
The original patch for Branches/2.0, with changed offset for 2.0.4, just for people who are still on 2.0.4 and could benefit from it

Download all attachments as: .zip

Change History (36)

markjaquith8 years ago

Patch for /trunk/

markjaquith8 years ago

patch for /branches/2.0/

markjaquith8 years ago

Helper script for /trunk/ --- creates something like 900 users. Place in /wp-admin/ and access via browser.

comment:1 markjaquith8 years ago

  • Keywords needs-testing added
  • Owner changed from anonymous to markjaquith
  • Status changed from new to assigned

create-lots-of-users.php is a helper script that I wrote for /trunk/ (won't work on /branches/2.0/) in order to facilitate mass import and mass deletion of users. Put it in your /wp-admin/ folder and then access it via browser. It'll create a crapload of users (somewhere around 900, I forget the exact number) by doing every combination of an array of first names and an array of last names.

It'll also give you the SQL queries you need to get rid of the users when you're done.

Using this, you can search for something like "jones" to get a result under 50, and search for "@comcast.net" to get a result of over 50.

comment:2 davidhouse8 years ago

  • Keywords has-patch added

Great work, Mark, everything worked flawlessly. While testing this, I came across a few old annoyances I thought I'd fix while I was in this area of WP. As such, here's my patch that contains all your fixes, plus a few extras:

  • If you have the edit_users cap, clicking 'Users' on the menu takes you to the user management page, instead of the 'Your profile' page. The order of those two pages in the Users submenu has been flipped to respect this change.
  • A lot of new users don't know you can click on the number of posts to see exactly those posts. I only found out months after using WP! Also, it was a tiny target to try and position your cursor over. So, I changed it into an action like the 'Edit' option: 'View n post(s)'. Perhaps we need a better wording here, I couldn't think of one that was sufficiently concise and clear.
  • I changed your patch to include the 'Results x-y of z' on every page, because I like it that way :)

I think that's all. See if you like it.

Oh, and bg|has-patch! Some of use actually use the 'Needs patch' report :)

comment:3 davidhouse8 years ago

Great work, Mark, everything worked flawlessly. While testing this, I came across a few old annoyances I thought I'd fix while I was in this area of WP. As such, here's my patch that contains all your fixes, plus a few extras:

  • If you have the edit_users cap, clicking 'Users' on the menu takes you to the user management page, instead of the 'Your profile' page. The order of those two pages in the Users submenu has been flipped to respect this change.
  • A lot of new users don't know you can click on the number of posts to see exactly those posts. I only found out months after using WP! Also, it was a tiny target to try and position your cursor over. So, I changed it into an action like the 'Edit' option: 'View n post(s)'. Perhaps we need a better wording here, I couldn't think of one that was sufficiently concise and clear.
  • I changed your patch to include the 'Results x-y of z' on every page, because I like it that way :)

I think that's all. See if you like it.

Oh, and bg|has-patch! Some of use actually use the 'Needs patch' report :)

davidhouse8 years ago

Several additions to Mark's patch; see my comment(s) below.

comment:4 davidhouse8 years ago

Oh, no 2.0-branch patch for me. Sorry, folks.

davidhouse8 years ago

Version 2, the old one had a hunk from an older patch.

comment:5 davidhouse8 years ago

Something else which was in my patch but I forgot to mention:

  • When you search for something, there was no way to get back to showing all the users. My extras include some 'Reset search' text which just pop you back to users.php.

markjaquith8 years ago

i18n fixes, moved the notification box above the search, reworded the link back to "all users"

comment:6 markjaquith8 years ago

2703.3 has i18n fixes, moves the notification box up above the search, and rewords the link back to "all users"

markjaquith8 years ago

Latest and greatest

comment:7 markjaquith8 years ago

2703.4 takes out a random change left in there by David (c'mon man... svn revert!), fixes menu highlighting, and fixes a remove_query_arg() bug I ran into (whereby its second param was required)

Looking pretty good at this point.

comment:8 davidhouse8 years ago

Looks great from where I'm sitting. Anyone else want to give this a whirl, then place a bc|commit on it?

markjaquith8 years ago

Latest and greatest 2

comment:9 markjaquith8 years ago

2793.5 does stripslashes() on search results before printing to search box, to avoid ugliness.

Ringmaster brought something up... when editing a user, like changing their role, you're brought back to the front page. I'm heading out the door, but I can fix this when I return.

markjaquith8 years ago

Latest and greatest 3

comment:10 markjaquith8 years ago

2793.6

  • Returns you to the page you were viewing, when you:
    • Create a new user
    • Change users' roles
    • Delete users
  • I cleaned up a lot of code... spaces to tabs, proper whitespace, etc.
  • Fixes for add_query_arg() and remove_query_arg()
    • No longer freaks out if you pass it a full URL with http:// or https://
    • You can now pass an array of keys to remove_query_arg() and it will remove them all (HANDY!)
    • Slashes are properly stripped on setups with magicquotes (in add_query_arg(), parse_str() is used, which slashes things if magicquotes is on)
  • When you delete users, the number of users you deleted is displayed in the resulting message.
  • Proper i18n, including use of __ngettext(), where applicable

markjaquith8 years ago

oops, fix user-edit.php submenu

markjaquith8 years ago

bigger, better

comment:11 markjaquith8 years ago

  • Keywords so-many-patches added

2793.8

  • Submenu for edit-user.php fixed
  • When you edit a user, you are given a link back to the users.php page you were on (i.e., search term and page number)
  • When you create a new user (JavaScript off), you are redirected to a users.php view of that user
  • When you attempt to create a new user (Javascript off), but there is an error, the HTML form is repopulated with your attempted data, and the error box appears below the form, just like how it works with the AJAX user creation. Now the user experience is identical with or without JavaScript

comment:13 ryan8 years ago

  • Milestone set to 2.1

Suggestions: Move the user search into the main wrap to maintain consistency with other management pages. Move the query logic into a local function so that template and backend code have some separation.

markjaquith8 years ago

reorganize search, put it all into one wrap

comment:14 markjaquith8 years ago

reorganize_users.php.diff does the wrap reorganization, and shuffles some other stuff around to look nicer.

Go ahead and apply that and I'll move the query logic into a local function (or maybe a class, there are quite a few variables to keep track of) next.

markjaquith8 years ago

Move user search/paging to a class

comment:16 markjaquith8 years ago

WP_User_Search_class.diff moves the search and paging to a class, defined near the top of the file, so that there is better code/template separation.

comment:17 ryan8 years ago

Nice. How about calling it WP_User_Query() and have the constructor support passing args in via associative array or query string the way we do in other places? Should we put this in admin-db.php? Are there other places we can use it right now?

comment:18 markjaquith8 years ago

Right now, it's pretty much a one-job class. With some more work, we could make it into a generic admin search/paging class, and use it for posts and comments as well. WP_Admin_Query

comment:19 ryan8 years ago

[3864] for WP_User_Search.

filosofo8 years ago

Adds alphabetizing feature to the paging

comment:20 filosofo8 years ago

I love this user paging. It's just what I needed for a site I'm
working on that has about 40,000 subscribers.

What I also needed I've attached as a patch: an alphabetizing system.

markjaquith8 years ago

The original patch for Branches/2.0, with changed offset for 2.0.4, just for people who are still on 2.0.4 and could benefit from it

comment:21 ryan8 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed
Note: See TracTickets for help on using tickets.