EDIT
开始和结束日期遵循日期格式。但您在元查询中使用的是数字类型转换。您需要使用日期类型,如
array(
\'key\' => \'user_registered\',
\'value\' => $start_date,
\'compare\' => \'>\',
\'type\' => \'DATE\'
),
array(
\'key\' => \'user_registered\',
\'value\' => $end_date,
\'compare\' => \'<=\',
\'type\' => \'DATE\'
)
希望这对你有帮助。
啊。。。还有一个问题。您正在将数据保存在$current_user_id
但您没有在第三个数组中使用此变量。试试这个
array(
\'key\' => \'referral_id\',
\'value\' => $current_user_id,
\'compare\'=> \'=\',
\'type\' => \'NUMERIC\'
)
完整代码:
$args = array(
\'meta_query\' => array(
array(
\'relation\' => \'AND\',
array(
\'key\' => \'user_registered\',
\'value\' => $start_date,
\'compare\' => \'>\',
\'type\' => \'DATE\'
),
array(
\'key\' => \'user_registered\',
\'value\' => $end_date,
\'compare\' => \'<=\',
\'type\' => \'DATE\'
),
array(
\'key\' => \'referral_id\',
\'value\' => $current_user_id,
\'compare\'=> \'=\',
\'type\' => \'NUMERIC\'
)
)
)
);
$users = get_users($args);
请立即尝试我的完整代码。