我在add user autocomplete插件中找到了以下类。它扩展了普通的searcha并允许“*”;
示例:$wp\\u user\\u search=new A2B\\u user\\u查询(数组(\'search\'=>$s.*\');
A2B\\u User\\u Query类扩展了WP\\u User\\u Query{/***@请参见WP\\u User\\u Query::get\\u search\\u sql()*/函数get\\u search\\u sql($string,$cols,$wild=false){$string=esc\\u sql($string);
// Always search all columns
$cols = array(
\'user_email\',
\'user_login\',
\'user_nicename\',
\'user_url\',
\'display_name\'
);
// Always do \'both\' for trailing_wild
$wild = \'both\';
$searches = array();
$leading_wild = ( \'leading\' == $wild || \'both\' == $wild ) ? \'%\' : \'\';
$trailing_wild = ( \'trailing\' == $wild || \'both\' == $wild ) ? \'%\' : \'\';
foreach ( $cols as $col ) {
if ( \'ID\' == $col )
$searches[] = "$col = \'$string\'";
else
$searches[] = "$col LIKE \'$leading_wild" . like_escape($string) . "$trailing_wild\'";
}
return \' AND (\' . implode(\' OR \', $searches) . \')\';
}
}