Whether you’re developing a custom contact form, comment or testimonial section in your WordPress site, you will need a strong anti-spam solution to protect yourself from bombardment of Spam content. Who else can give you better protection than inbuilt Akismet plugin in WordPress.
The PHP function uses Akismet plugin to check for spam content, just drop this PHP code in your functions.php in your active WordPress theme directory, and call it whenever you will need to check user submitted content for spam. Just make sure Akismet plugin is active.
Let’s say you want to check for spam in content submitted by a user :
This should return true if the submitted content is found to be spam by Akismet server.