• Hello,
    Is it possible to add additional message validation to the form?
    I want the form to throw an error if the message contains a URL. For my other sites, which use contact form 7, it uses the ‘Disallowed Comment Keys’ field in the Discussion settings of WordPress and for sites using gravity forms I have used a filter to hook into field validation as shown below.

    Is it possible to do something similar with this form plugin?

    Thanks

    Jo

    Gravity forms validation:

    // add custom validation to form
    add_filter( 'gform_field_validation_1_4', 'validate_1_4', 10, 4 );
    function validate_1_4( $result, $value, $form, $field ) {
        $nourl_pattern = '(===|http|https|www)';
        if ( preg_match( $nourl_pattern, $value ) ) {
        $result['is_valid'] = false;
        $result['message']  = 'Message can not contain special characters or website addresses.';
    }
    return $result;
    }
Viewing 1 replies (of 1 total)
  • Plugin Author Alan Fuller

    (@alanfuller)

    There is a filter cscf_spamfilter you could use

    It basically stops the email being sent, it wont reject back to the user, you will have to manage what you do with the message.

    If you want to validate and respond to the user, as per your example, the a filter or action hook would need to be added to cscf_Contact->IsValid()
    If you want to contribute such code, then you can here https://github.com/alanef/plugin-clean-and-simple-contact-form-project

    • This reply was modified 3 years, 6 months ago by Alan Fuller.
Viewing 1 replies (of 1 total)
  • The topic ‘Message validation’ is closed to new replies.