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(),
|
'include' => array(),
|
||||||
'exclude' => array(),
|
'exclude' => array(),
|
||||||
'search' => '',
|
'search' => '',
|
||||||
|
'search_columns' => array(),
|
||||||
'orderby' => 'login',
|
'orderby' => 'login',
|
||||||
'order' => 'ASC',
|
'order' => 'ASC',
|
||||||
'offset' => '',
|
'offset' => '',
|
||||||
|
@ -476,14 +477,19 @@ class WP_User_Query {
|
||||||
if ( $wild )
|
if ( $wild )
|
||||||
$search = trim($search, '*');
|
$search = trim($search, '*');
|
||||||
|
|
||||||
if ( false !== strpos( $search, '@') )
|
$search_columns = array();
|
||||||
$search_columns = array('user_email');
|
if ( $qv['search_columns'] )
|
||||||
elseif ( is_numeric($search) )
|
$search_columns = array_intersect( $qv['search_columns'], array( 'ID', 'user_login', 'user_email', 'user_url', 'user_nicename' ) );
|
||||||
$search_columns = array('user_login', 'ID');
|
if ( ! $search_columns ) {
|
||||||
elseif ( preg_match('|^https?://|', $search) )
|
if ( false !== strpos( $search, '@') )
|
||||||
$search_columns = array('user_url');
|
$search_columns = array('user_email');
|
||||||
else
|
elseif ( is_numeric($search) )
|
||||||
$search_columns = array('user_login', 'user_nicename');
|
$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 );
|
$this->query_where .= $this->get_search_sql( $search, $search_columns, $wild );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue