0

i use the following code for count the authors

    $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 . ')';

i need a count from authors who have the role frontend vendor or who have published a downlaod post.

any idea? thanks for help

1 Answer 1

0

to get the number of authors who are assigned a particular role the get_users() function should do it:

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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.