Joe
Joe

Reputation: 13

Changing Contact Form 7 alert message after submit based on input value

Does anyone know how to change cf7 alert message when the input value is greater than 10?

If input value = 11 or up change the cf 7 alert message after submitting it.

enter image description here

Thanks for your help.

Upvotes: 1

Views: 720

Answers (1)

Howard E
Howard E

Reputation: 5639

You could hook into the before_send_mail and update the message based on a specific field.

add_action ('wpcf7_before_send_mail', 'dd_before_send_mail');
function dd_before_send_mail($contact_form){
    // Get the instance
    $submission = WPCF7_Submission :: get_instance();
    if ($submission){
        $fields = $submission->get_posted_data();
        // put your field name in for [your-field]
        if (intval($fields['your-field'] ) > 10 ) {
            $contact_form -> set_properties(array('messages' => array('mail_sent_ok' => 'This is your message')));
        }
    }
}

Upvotes: 1

Related Questions