我想用WP_User_Query
类根据用户的特定meta
字段。
当我使用简单的单元查询时,它工作得很好:
$q = new WP_User_Query( array(
\'role\' => \'contributor\',
\'fields\' => \'all_with_meta\',
\'meta_key\' => \'first_meta\',
\'meta_value\' => \'2\'
) );
但当我尝试进行组合式两字段查询并查找已填充的用户时second_meta
元字段,查询列出所有贡献者(元查询根本不工作): $q = new WP_User_Query( array(
\'role\' => \'contributor\',
\'fields\' => \'all\',
\'meta_query\' => array(
\'relation\' => \'AND\',
0 => array(
\'meta_key\' => \'first_meta\',
\'meta_value\' => \'2\'),
1 => array(
\'meta_key\' => \'second_meta\',
\'meta_value\' => \'\',
\'meta_compare\' => \'!=\'
)
)
) );
如何使此组合元查询工作?当然,我正试图找到所有作为贡献者的用户first_meta
==2和second_meta
不为空