• Resolved Sajan sharma

    (@sajan08)


    hi,

    Thanx for this plugin and it is very helpful to us. please help me to block specific words in line which is entered by user.
    thnx & regards
    sajan sharma

Viewing 1 replies (of 1 total)
  • Thread Starter Sajan sharma

    (@sajan08)

    Hi, i solved this issue by using below code in path:- ../plugins/contat-form-c7/modules/textarea.php file instead of validation filter.

    code as follows:-

    // Contact form 7 custom validation for spam in message lines

    add_filter( ‘wpcf7_validate_textarea’, ‘custom_text_confirmation_validation_filter’, 10, 2 );
    add_filter( ‘wpcf7_validate_textarea*’, ‘custom_text_confirmation_validation_filter’, 10, 2 );

    function custom_text_confirmation_validation_filter( $result, $tag ) {

    // Add your spam words below, separated by ‘,’
    $bads = array(“seo”,”advertisement”,”advertise”,’SEO’,’ADVERTISEMENT’,’ADVERTISE’);

    // Specify the name of the Contact Form 7 field that you want to check for spam
    $filter_field = “your-message”;
    if ( $filter_field == $tag->name) {
    $your_subject = isset( $_POST[$filter_field] ) ?
    trim( $_POST[$filter_field] ) : ”;

    foreach($bads as $a) {
    $a=preg_quote($a,’\\’);
    if(preg_match(“/$a/”,$your_subject)) {
    $result->invalidate( $tag,’Please do not spam this contact form.’);
    }
    }
    }

    return $result;
    }

Viewing 1 replies (of 1 total)
  • The topic ‘how to block words of line in textarea’ is closed to new replies.