From 433f6600c0de8ca32e7af74c6fb1b626cdc87be6 Mon Sep 17 00:00:00 2001 From: Drew Jaynes Date: Sat, 3 Oct 2015 07:23:20 +0000 Subject: [PATCH] Users: Introduce the `users_list_table_query_args` filter, for modifying the `WP_User_Query` arguments used within the `prepare_items()` methods in the users list tables. The current list table is passed as a second parameter, `$this`, and can take the form of either a `WP_Users_List_Table` or `WP_MS_Users_List_Table` instance depending on the context in which the filter was evaluated. Props juliobox for the initial patch. Fixes #25360. git-svn-id: https://develop.svn.wordpress.org/trunk@34796 602fd350-edb4-49c9-b593-d223f7449a82 --- .../includes/class-wp-ms-users-list-table.php | 3 +++ src/wp-admin/includes/class-wp-users-list-table.php | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/wp-admin/includes/class-wp-ms-users-list-table.php b/src/wp-admin/includes/class-wp-ms-users-list-table.php index 8e9dbdbbfd..6a2e47cc00 100644 --- a/src/wp-admin/includes/class-wp-ms-users-list-table.php +++ b/src/wp-admin/includes/class-wp-ms-users-list-table.php @@ -75,6 +75,9 @@ class WP_MS_Users_List_Table extends WP_List_Table { $mode = empty( $_REQUEST['mode'] ) ? 'list' : $_REQUEST['mode']; + /** This filter is documented in wp-admin/includes/class-wp-users-list-table.php */ + $args = apply_filters( 'users_list_table_query_args', $args, $this ); + // Query the user IDs for this page $wp_user_search = new WP_User_Query( $args ); diff --git a/src/wp-admin/includes/class-wp-users-list-table.php b/src/wp-admin/includes/class-wp-users-list-table.php index 8ff21ffef6..93a6b2c5fe 100644 --- a/src/wp-admin/includes/class-wp-users-list-table.php +++ b/src/wp-admin/includes/class-wp-users-list-table.php @@ -107,6 +107,17 @@ class WP_Users_List_Table extends WP_List_Table { if ( isset( $_REQUEST['order'] ) ) $args['order'] = $_REQUEST['order']; + /** + * Filter the query arguments used to retrieve users for the current users list table. + * + * @since 4.4.0 + * + * @param array $args Arguments passed to WP_User_Query to retrieve items for the current + * users list table. + * @param mixed $this The current WP_Users_List_Table or WP_MS_Users_List_Table instance. + */ + $args = apply_filters( 'users_list_table_query_args', $args, $this ); + // Query the user IDs for this page $wp_user_search = new WP_User_Query( $args );