# Hold Comments Written in All Capitals

> Sends comments that are mostly in capital letters to the moderation queue instead of publishing them straight away.

- Type: PHP
- Runs: Run everywhere
- Category: [Comments](https://wpide.com/library/category/comments/)
- Tags: comments, moderation, spam
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/hold-all-caps-comments/

## Code

```php
// Share of uppercase letters (0 to 1) above which a comment is held.
$wpide_caps_ratio = 0.7;

add_filter( 'pre_comment_approved', function ( $approved, $commentdata ) use ( $wpide_caps_ratio ) {
    if ( 1 !== $approved && '1' !== $approved ) {
        return $approved;
    }

    $letters = preg_replace( '/[^\p{L}]/u', '', (string) $commentdata['comment_content'] );
    $upper   = preg_replace( '/[^\p{Lu}]/u', '', $letters );

    if ( strlen( $letters ) >= 20 && strlen( $upper ) / strlen( $letters ) > $wpide_caps_ratio ) {
        return 0;
    }

    return $approved;
}, 20, 2 );
```

## Notes

Short comments (under 20 letters) are never held.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Hold Comments Written in All Capitals" 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/
