Answer the question
In order to leave comments, you need to log in
How to abort a Contact Form 7 submission?
I use the following hook for Contcact Form 7
add_action("wpcf7_posted_data", "wpcf7_modify_this");
function wpcf7_modify_this($posted_data) {
$url = strpos($posted_data['your-message'], 'http://');
if ($url) {
return false;
}
return $posted_data;
}
Answer the question
In order to leave comments, you need to log in
You need to use the wpcf7_validate_ dynamic hook.
More or less like this:
add_filter( 'wpcf7_validate_textarea', 'custom_textarea_validation_filter', 20, 2 );
add_filter( 'wpcf7_validate_textarea*', 'custom_textarea_validation_filter', 20, 2 );
function custom_textarea_validation_filter( $result, $tag ) {
if ( 'your-message' == $tag->name ) {
$your_message = isset( $_POST['your-message'] ) ? trim( $_POST['your-message'] ) : '';
if ( strpos($your_message, 'http://') !== false ) {
$result->invalidate( $tag, "Incorrect value" );
}
}
return $result;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question