Make WordPress Core

Opened 11 years ago

Last modified 5 years ago

#23413 new enhancement

Provide query result data to custom user columns

Reported by: johnc28's profile JohnC28 Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Users Keywords: needs-patch 2nd-opinion
Focuses: administration Cc:

Description

When the filter manage_users_custom_column is triggered, it sends an empty string for the value field.

Since it's easy enough to extend the WP_User_Query with extra fields, it would be good to have those fields passed through if they exist to save having to requery the database with the user_id parameter to get the data.

I have attached a patch to show what I mean.

Attachments (1)

class-wp-users-list-table.php.diff (632 bytes) - added by JohnC28 11 years ago.

Download all attachments as: .zip

Change History (4)

#1 @SergeyBiryukov
11 years ago

I guess plugins might expect an empty string. An example:
http://plugins.trac.wordpress.org/browser/document-repository/tags/0.2.4/user-roles.php#L82

Another option might be to pass $user_object as the fourth parameter.

The filter is also used in class-wp-ms-users-list-table.php:
http://core.trac.wordpress.org/browser/tags/3.5.1/wp-admin/includes/class-wp-ms-users-list-table.php#L262

#2 @chriscct7
9 years ago

  • Focuses administration added
  • Keywords dev-feedback needs-patch added; has-patch removed

We could check to see if anyone used the filter and if not, then use John's proposed solution to backfill the value to avoid the db queries. That preserves backwards compatibility for the couple of plugins that expect the first param to be an empty string while avoiding needless db calls for those who don't use those plugins (the vast majority of WP users).

#3 @johnbillion
9 years ago

  • Keywords 2nd-opinion added; dev-feedback removed

Does this actually cause an extra DB query? The user data should be sitting in the object cache at this point.

Note: See TracTickets for help on using tickets.