Add search_columns arg to WP_User_Query to allow for explicit column choices. Without it, the columns will be detected based on the search term. see #19810.
git-svn-id: http://svn.automattic.com/wordpress/trunk@19882 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
6025a35ccf
commit
cf22bbb523
|
@ -378,6 +378,7 @@ class WP_User_Query {
|
|||
'include' => array(),
|
||||
'exclude' => array(),
|
||||
'search' => '',
|
||||
'search_columns' => array(),
|
||||
'orderby' => 'login',
|
||||
'order' => 'ASC',
|
||||
'offset' => '',
|
||||
|
@ -476,14 +477,19 @@ class WP_User_Query {
|
|||
if ( $wild )
|
||||
$search = trim($search, '*');
|
||||
|
||||
if ( false !== strpos( $search, '@') )
|
||||
$search_columns = array('user_email');
|
||||
elseif ( is_numeric($search) )
|
||||
$search_columns = array('user_login', 'ID');
|
||||
elseif ( preg_match('|^https?://|', $search) )
|
||||
$search_columns = array('user_url');
|
||||
else
|
||||
$search_columns = array('user_login', 'user_nicename');
|
||||
$search_columns = array();
|
||||
if ( $qv['search_columns'] )
|
||||
$search_columns = array_intersect( $qv['search_columns'], array( 'ID', 'user_login', 'user_email', 'user_url', 'user_nicename' ) );
|
||||
if ( ! $search_columns ) {
|
||||
if ( false !== strpos( $search, '@') )
|
||||
$search_columns = array('user_email');
|
||||
elseif ( is_numeric($search) )
|
||||
$search_columns = array('user_login', 'ID');
|
||||
elseif ( preg_match('|^https?://|', $search) )
|
||||
$search_columns = array('user_url');
|
||||
else
|
||||
$search_columns = array('user_login', 'user_nicename');
|
||||
}
|
||||
|
||||
$this->query_where .= $this->get_search_sql( $search, $search_columns, $wild );
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue