I'm looking for a way to check that a post has a minimum word count before allowing it to be sent for review (added to the pending post status).
Below is the code I have:
if (current_user_can('contributor')) {
function minWord($content){
global $post;
$num = 150; //set this to the minimum number of words
$content = $post->post_content;
if (str_word_count($content) < $num)
wp_die( __('Error: your post is below the minimum word count.') );
}
add_action('draft_to_pending', 'minWord');
}
This appears to "work", in that it brings up an error message when the word count is indeed below 150. However, the post is still saved as a "pending". Is there any way to prevent the post from being made pending, but instead keep it saved as "draft".
Cheers
Peter