如何使用多个角色参数获取 WP_User_Query

San*_*ate 2 wordpress

我有两个用户角色

1) 供应商 2) 免费供应商

在这里,我试图通过用户角色vendorfreevendor波纹管代码获取用户,但查询仅获取freevendor

$vendor_total_args = array (
    'role' => 'vendor',
    'role' => 'freevendor',
   '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'
        )
    )
);
Run Code Online (Sandbox Code Playgroud)

那么我如何获取多个用户角色 vendorfreevendor使用上面的代码片段。

bir*_*ire 5

再等几天......对于WordPress 4.4(预定12月初)

然后你可以只使用新属性:

'role__in' => array( 'vendor', 'freevendor' );
Run Code Online (Sandbox Code Playgroud)

在的WP_User_Query类。

请注意,还有用于排除多个用户角色的 'role__not_in' 属性。

这是最近刚刚解决的核心增强票 #22212