Count user posts by user ID, Post type and Post status

Here is a quick solution to get the post count any kind of filtering you want

function custom_get_user_posts_count($user_id,$args );  
    $args['author'] = $user;
    $args['fields'] = 'ids';
    $ps = get_posts($args);
    return count($ps);
}

Since this function uses get_posts you can filter and use anything that you can with WP_Query

So in your case you can use it like this:

$count = custom_get_user_posts_count($user_id, array(
    'post_type' =>'post',
    'post_status'=> 'draft'
));

Leave a Comment