+ // Set $post_status based on $author_found and on author's publish_posts capability
+ if ($author_found) {
+ $user = new WP_User($post_author);
+ if ($user->has_cap('publish_posts'))
+ $post_status = 'publish';
+ else
+ $post_status = 'pending';
+ } else {
+ // Author not found in DB, set status to pending. Author already set to admin.
+ $post_status = 'pending';
+ }
+
+ $subject = trim($subject);