This might not directly answer your question (because I haven’t even thought about why the $_POST['submit']
would be ignored or if it is even correct), but you should use filters/actions whenever possible.
The correct filter for filtering comment text is pre_comment_content
, and you should use it like this:
function my_filter_comment_for_swear_words( $comment_content ) {
// Verify if $comment_content contains swear words here
// return $comment_content if it doesn't contain forbidden words
// or wp_die if it does
}
add_filter( 'pre_comment_content', 'my_filter_comment_for_swear_words' );
This code would, as usual, go into your functions.php
file or into your custom plugin (depending on what your setup is).