我目前正在根据用户角色列出帖子,查询如下:
$ids = get_users( array(\'role\' => \'author\' ,\'fields\' => \'ID\') );
$args = array(
\'author\' => implode(\',\', $ids),
\'orderby\' => \'date\',
\'order\' => \'ASC\',
);
是否有可能根据作者的会员级别使用付费会员Pro来限制帖子?该插件具有以下钩子来检查用户级别:
if(pmpro_hasMembershipLevel($level_id))
但我不确定如何将其合并到上述查询中(如果可能)?
最合适的回答,由SO网友:Domain 整理而成
$ids = get_users( array(\'role\' => \'author\' ,\'fields\' => \'ID\') );
$contr_limit = count($ids);
for($cntr=0; $cntr < $contr_limit; $cntr++){
if( pmpro_hasMembershipLevel($level_id, $ids[$cntr] ) !== true ){
unset($ids[$cntr]);
}
}
$args = array(
\'author\' => implode(\',\', $ids),
\'orderby\' => \'date\',
\'order\' => \'ASC\',
);