Hi,
This is how I target for custom errors:
add_filter( 'wpcf7_display_message', 'validaiton_messages_fail', 10, 2 );
function validaiton_messages_fail( $message, $status ) {
$submission = WPCF7_Submission::get_instance();
if ( $submission->is( 'validation_failed' ) ) {
$posted_data = $submission->get_posted_data();
$message = __( 'your cusotm error message', '');
}
elseif ( $submission->is( 'mail_failed' ) ) {
$posted_data = $submission->get_posted_data();
$message = __( 'your cusotm error message', '');
}
elseif ( $submission->is( 'spam' ) ) {
$posted_data = $submission->get_posted_data();
$message = __( 'your cusotm error message', '');
}
return $message;
}
-
This reply was modified 7 years, 3 months ago by
Lukasz.
Sorry, doesn’t work for me. Thank you for the effort, I do appreciate it.
In the class WPCF7_Submission there is a function submit() that runs the validate() function, which returns false (upon my custom spamfilter that has a positive). Then it will set the status to validation_failed. I don’t see any way to get it to return a custom status. This part of the code always seem to overwrite my custom status.
If I decide to have it validate, it will happily send the mail, which in my spamfilter isn’t a good idea.
It seems to be better to not just validate, but to use the wpcf7_spam filter to set $spam = true and work with that. Maybe it fits in better anyway.
I have to say thank you 🙂
That filter for messages did set me on the right path.
I am not using a status anymore for my spamfilters.
I am setting $spam to true when my spamfilter are marking positive.
With that message filter I am now adding custom messages in case the status is spam.