# Reject WPForms Messages in Foreign Scripts

> Blocks WPForms submissions written mostly in Cyrillic, Chinese or another script your business never receives genuine messages in.

- Type: PHP
- Runs: Run everywhere
- Category: [Forms](https://wpide.com/library/category/forms/)
- Tags: wpforms, spam, language
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/wpforms-non-latin-spam/

## Code

```php
$wpide_wpf_blocked_scripts = array( 'Cyrillic', 'Han', 'Arabic', 'Hangul', 'Thai' );
$wpide_wpf_script_share    = 0.3;

add_filter( 'wpforms_process_honeypot', function ( $honeypot, $fields, $entry, $form_data ) use ( $wpide_wpf_blocked_scripts, $wpide_wpf_script_share ) {
    if ( $honeypot || empty( $entry['fields'] ) ) {
        return $honeypot;
    }

    $text = '';
    foreach ( (array) $entry['fields'] as $value ) {
        $text .= ' ' . ( is_array( $value ) ? implode( ' ', $value ) : (string) $value );
    }

    $letters = preg_match_all( '/\p{L}/u', $text );
    if ( $letters < 10 ) {
        return $honeypot;
    }

    $foreign = 0;
    foreach ( $wpide_wpf_blocked_scripts as $script ) {
        $foreign += (int) preg_match_all( '/\p{' . $script . '}/u', $text );
    }

    return $foreign / $letters >= $wpide_wpf_script_share ? 'Your message could not be sent.' : $honeypot;
}, 10, 4 );
```

## Notes

Remove scripts from the list that your customers actually write in.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Reject WPForms Messages in Foreign Scripts" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
