根据输入值提交后更改 Contact Form 7 警报消息

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

有谁知道当输入值大于 10 时如何更改 cf7 警报消息?

如果输入值 = 11 或以上,请在提交后更改 cf 7 警报消息。

感谢您的帮助。

您可以连接到 before_send_mail 并根据特定字段更新消息。

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')));
        }
    }
}