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


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 );
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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