# Check Your Own Form Submissions With Akismet

> Adds a wpide_akismet_is_spam() helper that sends a name, email and message from any custom form to Akismet and tells you whether it looks like spam, so your hand-built forms get the same protection as comments.

- Type: PHP
- Runs: Run everywhere
- Category: [Plugin Integrations](https://wpide.com/library/category/integrations/)
- Tags: akismet, forms, spam
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/akismet-check-custom-form/

## Code

```php
if ( ! function_exists( 'wpide_akismet_is_spam' ) ) {
    function wpide_akismet_is_spam( array $fields ) {
        if ( ! class_exists( 'Akismet' ) || ! Akismet::get_api_key() ) {
            return false;
        }

        $request = array(
            'blog'                 => home_url(),
            'blog_lang'            => get_locale(),
            'blog_charset'         => get_option( 'blog_charset' ),
            'user_ip'              => isset( $_SERVER['REMOTE_ADDR'] ) ? sanitize_text_field( wp_unslash( $_SERVER['REMOTE_ADDR'] ) ) : '',
            'user_agent'           => isset( $_SERVER['HTTP_USER_AGENT'] ) ? sanitize_text_field( wp_unslash( $_SERVER['HTTP_USER_AGENT'] ) ) : '',
            'referrer'             => wp_get_raw_referer() ? wp_get_raw_referer() : '',
            'permalink'            => wp_get_referer() ? wp_get_referer() : home_url( '/' ),
            'comment_type'         => 'contact-form',
            'comment_author'       => isset( $fields['name'] ) ? (string) $fields['name'] : '',
            'comment_author_email' => isset( $fields['email'] ) ? (string) $fields['email'] : '',
            'comment_content'      => isset( $fields['message'] ) ? (string) $fields['message'] : '',
        );

        $response = Akismet::http_post( Akismet::build_query( $request ), 'comment-check' );

        return is_array( $response ) && isset( $response[1] ) && 'true' === trim( $response[1] );
    }
}
```

## Notes

Call wpide_akismet_is_spam( array( 'name' => ..., 'email' => ..., 'message' => ... ) ) in your form handler; it returns false when Akismet is missing or unreachable, so submissions are never lost.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Check Your Own Form Submissions With Akismet" 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/
