仅前端供应商角色的用户数

时间:2014-06-28 作者:Mike

我使用以下代码计算作者数

    $count_posts = wp_count_posts( \'download\' );
    echo \'Published eBook (\' . $count_posts->publish .  \')\';
    echo \' \';
    global $wpdb; 
    $user_count = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->users;" );
    echo \'  Published Authors (\' . $user_count . \')\';
我需要一个从谁的角色前端供应商或谁已经发表了downlaod文章作者计数。

有什么想法吗?谢谢你的帮助

1 个回复
SO网友:Will

要获取分配给特定角色的作者数量get_users() 函数应执行以下操作:

$args = array(
\'role\' => \'frontend_vendor\',//substitute your role here as needed
\'fields\' => \'ID\',
);

$users = get_users( $args );
$user_count = count( $users );

结束

相关推荐

从wp_USERS中选择,也获取DisplayName

SELECT post_author, count(ID) as amount FROM dbold_posts WHERE WEEKOFYEAR( post_date ) = WEEKOFYEAR( NOW() ) AND post_status = \'publish\' AND post_type = \'post\' GROUP BY post_author 我不知道如何获取显示名称,而不是此查询中的“post\\