[Resolved] How to retrieve the number of pending posts for an author?
I’ve got a site where I’d like to keep track of how many “pending” posts each user has. I think I can use a query with $wpdb->get_var to do this, but am having trouble with it.
Here’s the code I’m using, based on what I found at another topic:
global $wpdb; $where = "WHERE post_status = 'pending' AND post_author = " . $user_id; $post_count = $wpdb->get_var( "SELECT COUNT (*) FROM $wpdb->posts $where"); $welcomemessage .= "<p>You currently have $post_count submissions pending.</p>";
Problem is, $post_count doesn’t seem to be getting any data at all. The output is simply “You currently have submissions pending.”
Am I doing something wrong here?
- The topic ‘[Resolved] How to retrieve the number of pending posts for an author?’ is closed to new replies.