您可以尝试下面的代码,将user\\u email列中匹配记录的对象返回到wordpress数据库用户表中。
/*
This function will return object of all match user records
Function Location : themes/function.php
*/
function get_domain_user($domains){
global $wpdb;
//Build query for match records selection using RLIKE
$strdomain = \'\';
foreach( $domains as $domain ) :
if($strdomain == \'\'){
$strdomain = "\'" . $domain;
}
else {
$strdomain = $strdomain . "|" . $domain;
}
endforeach;
$strdomain = \'user_email RLIKE \' . $strdomain . "\'";
//Execute query for pull all respected records...
$strQuery = "SELECT * FROM $wpdb->users WHERE $wpdb->users.$strdomain";
return $user_query = $wpdb->get_results($strQuery);
}
调用此函数,如下所示:
//Email address domain array...
$domains = array(\'domain1.com\', \'domain2.com\', \'domain3.com\');
//Pull records which users email address contain $domains mail address...
$user_list = get_domain_user( $domains );
如果对此有任何问题/疑问/担忧,请与我联系。