WP_User_Query
只接受一个“role”参数,并且由于数组具有相同的键两次,因此只使用第二个键:
array(
\'role\' => \'vendor\',
\'role\' => \'freevendor\',
);
与以下内容相同:
array(
\'role\' => \'freevendor\',
);
您可以进行两次调用,每个角色集一次:
$user_query_args = array (
\'role\' => \'vendor\',
\'orderby\' => $orderby,
\'order\' => $order,
\'meta_query\' => array(
\'relation\' => \'AND\',
array(
\'key\' => \'pv_merchant__experiance_dropdwon\',
\'value\' => $_POST[ \'pv_merchant__experiance_dropdwon1\' ],
\'compare\' => \'LIKE\'
),
array(
\'key\' => \'pv_merchant_specialization\',
\'value\' => $_POST[ \'pv_merchant__experiance_dropdwon2\' ],
\'compare\' => \'LIKE\'
)
)
);
$vendors = new WP_User_Query( $user_query_args )->results;
$user_query_args[\'role\'] = \'freevendor\';
$freevendors = new WP_User_Query( $user_query_args )->results;
然后合并这两个结果集。或者看看注释,它显示了如何编写结合这两个角色的元查询。