user_search_columns
Filters the columns to search in a WP_User_Query search.
The default columns depend on the search term, and include 'ID', 'user_login', 'user_email', 'user_url', 'user_nicename', and 'display_name'.
Usage
add_filter( 'user_search_columns', 'wp_kama_user_search_columns_filter', 10, 3 ); /** * Function for `user_search_columns` filter-hook. * * @param string[] $search_columns Array of column names to be searched. * @param string $search Text being searched. * @param WP_User_Query $query The current WP_User_Query instance. * * @return string[] */ function wp_kama_user_search_columns_filter( $search_columns, $search, $query ){ // filter... return $search_columns; }
- $search_columns(string[])
- Array of column names to be searched.
- $search(string)
- Text being searched.
- $query(WP_User_Query)
- The current WP_User_Query instance.
Changelog
Since 3.6.0 | Introduced. |
Where the hook is called
wp-includes/class-wp-user-query.php 741
$search_columns = apply_filters( 'user_search_columns', $search_columns, $search, $this );