The function count_user_posts
only accepts a user ID so you arguments are never taken in consideration.
Here is a simple function to get the count by status
function count_user_posts_by_status($post_status="publish",$user_id = 0){
global $wpdb;
$count = $wpdb->get_var(
$wpdb->prepare(
"
SELECT COUNT(ID) FROM $wpdb->posts
WHERE post_status = %s
AND post_author = %d",
$post_status,
$user_id
)
);
return ($count) ? $count : 0;
}
Usage:
<?php echo count_user_posts_by_status('draft',$userID); ?>
Related Posts:
- C++ – how to find the length of an integer
- How can I make a PHP counter?
- Counting the posts of a loop (WP_Query)?
- Category and children post count
- Hide the post count behind Post Views (Remove All, Published and Trashed) in Custom Post Type
- How to display 2 equal columns of li based on the count of items in wp_nav_menu divided by 2?
- Show weekly posts statistic in WordPress
- Increasing post view count automatically [duplicate]
- Count number of posts by author in a category
- What is the best way to count and display the number of posts?
- Get count of terms with a post and another taxonomy term?
- Get Gravity Forms field values and count how many? [closed]
- Counting posts in custom post type by author
- Show ellipsis (…) only if the number of characters exceeds limit defined in substr
- Get total views of all posts by author
- Count post + add number =
- How to do simple addition to increase favorites count of my wordpress posts
- Count posts published in one particular day: the lighter way
- What is the best way to do this? [closed]
- Search Count WordPress Theme
- How to read out the excerpt length (for if-condition)
- $count_posts->draft & published
- CountPost WordPress Custom Taxonomy
- get the count of table rows
- How to calculate posts number? [closed]
- How make animation increase of number
- Having problems getting the number of plays in a WordPress Playlist from an audio file
- How to show the amount of post that have on the site?
- Counting the number of elements with the values of x in a vector
- PHP 7.2 – Warning: count(): Parameter must be an array or an object that implements Countable
- How can I count the occurrences of a list item?
- Count how many files in directory PHP
- count posts from custom taxonomy terms by year
- Comment Count for each Comment Author
- Display user’s total comment count outside The Loop
- Count posts that have specific taxonomy term attached
- Count number of post in Taxonomy?
- User Published Post Count
- How to use global post counter in the loop?
- Taxonomy list. Order by a specific custom post type count
- Show that current post is number X out of X
- How to get the number of child categories a specific parent category has?
- Check if an array of posts has posts from a specific category
- get_queried_object error How to show post count by month in the taxonomy page
- wp_count_posts, wp_count_terms and wp_count_comments for specific user?
- How to count custom post types with conditional operators
- Count posts with specific term_meta
- How to count rows of table in the_content()
- Display posts count in front of the tag, for each tag
- right_now_content_table_end function not working?
- How can I count post views of REST API calls and update them in an ACF field?
- User’s total comment count excluding comments on their own posts
- Post count by month of taxonmy term
- custom post type category count shortcode
- How to update the counter of private pages in the dashboard?
- Counting posts with argument without retrieving the posts
- Show posts count for Categories and Tags in wp_nav_menu
- How to add category post count in main navigation menu [closed]
- How to show the number of website visitors in my theme
- How to count the number of archives there are
- Single.php Category Post Count
- Display count of new members registered today [closed]
- Post loop count is not in order
- How can i count post from my post type taxonomy
- How can i count the post added in relationship field, theme display
- Show the amount of posts in a tag in a specific category has
- How can I count ACF sub_field with a certain value
- How do I insert a after every 5 posts in a WordPress Loop that infinitely loads posts?
- Get Author Count By Day, Week and Month
- How to count other posts not having specific taxonomy terms?
- counting trackbacks, pingbacks and comments of a post
- Divide post content in three columns
- How to Define Custom Number of Items in Comment Feed
- Order terms by count – missing terms
- Count user posts and store the number for later use
- How include comment and post count of user in this custom query
- Allow a specific user role I have created to only upload one image to his media library
- Author post count in category
- How can I show how much water got saved on this order (making use of the number of items bought) on a thank-you-page?
- get_queried_object not work in taxonomy page
- Show post count in custom taxonomy page
- How Can I add show_post_count in get_archives_link?
- Modify the category post counting function
- Implementation to count page visits of unique visitors based on a cookie
- Display number of post published every day
- Add subcategories posts to the counts column at the admin’s categories list
- WPDB delivers wrong results from complex queries
- count_posts to a standalone link
- For each 3 posts, show a different post type
- divide custom field values in div every two values
- Counting custom post type with wp_count_posts returns an empty object
- How to mark every 3rd post
- Add a minimum word count to Excerpt (and how to force Excerpt as a rule for WyPiekacz)
- How to add a post counter to the list of custom taxonomy terms?
- How to limit the number of posts a user can publish based on user type
- ho can I get the number of the current post instead of the post id?
- How to add together (get the sum) a field from all author’s posts
- Counting number of identical meta keys
- How do I count the number of pages a user has seen on my site, and force them to log in after a certain amount
- Count the number of matching post names in foreach loop