Skip to content

Instantly share code, notes, and snippets.

@mehrshaddarzi
Last active June 19, 2020 06:53
Show Gist options
  • Save mehrshaddarzi/86c5f72fec63a5ee0a7ad5bf0dbb2f12 to your computer and use it in GitHub Desktop.
Save mehrshaddarzi/86c5f72fec63a5ee0a7ad5bf0dbb2f12 to your computer and use it in GitHub Desktop.
Add support for the "display_name" search column in WP_User_Query
<?php
add_filter( 'user_search_columns', 'filter_function_name', 10, 3 );
function filter_function_name( $search_columns, $search, $wp_user_query ) {
$search_columns[] = 'user_url';
return $search_columns;
}
//Where 'filter_function_name' is the function WordPress should call when filter is run. Note that the filter function must return an value after it is finished processing or the search terms will be empty.
//filter_function_name should be unique function name. It cannot match any other function name already declared.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment