Contact form 7 custom validation


I use wppb ( for my plugin and I’d like to set a form as invalid.
I would like to invalidate a whole form, not an individual field. This functionality exists in Gravity forms.

I am using this hook:

private function define_public_hooks()
$plugin_public = new Unitel_Sim_Registration_Public( $this->get_plugin_name(), $this->get_version() );
$this->loader->add_action( 'wpcf7_before_send_mail', $plugin_public, 'before_email_send', 10, 2 );

Though, I’m not sure if wpcf7_before_send_mail is the correct hook for this.


public function before_email_send( $contact_form )
$submission = WPCF7_Submission::get_instance();
$posted_data = $submission->get_posted_data();
$email = sanitize_email($posted_data['uscr-email']);
$cvr = sanitize_text_field($posted_data['uscr-cvr']);
$customer = $this->customer_exists( $email, $cvr ); // checks if email and cvr exist in custom database table, return true or false

if ( ! $customer )
    // customer does not exist with credentials provided
    // stop form submission and show generic error message, like 'Customer not found'
    // how can I do that?

I know this is off-topic, I wrote on plugin support, but I didn’t get any reply.

Roland 2 months 2023-04-11T05:34:11-05:00 0 Answers 0 views 0

Leave an answer