I want to count author posts and store this number for later use even if some of the posts have been deleted in the meantime.
$rows = $wpdb->get_results( $wpdb->prepare( "SELECT post_status, COUNT(ID) as count FROM $wpdb->posts WHERE post_author = %d AND post_type = 'post_type' GROUP BY post_status", $current_user->ID ) );
$stats = array();
foreach ( $rows as $row )
$stats[ $row->post_status ] = $row->count;
$post_count_published = isset($stats['publish']) ? $stats['publish'] : 0;
Any idea how this can be achieved?