How to make anti-spam contact form with Akismet
If you have a blog, you will get spam, that’s almost certain. The good news is in wordpress, akismet has got it under control. But what if you want have a contact form in your blog and also want it to be protected by akismet. Well, there are few ways to do this. If you don’t familiar with PHP, you can download the Akismet version of contact form plugin for Wordpress. Here is the full instruction of how to install it. Or you could integrate Akismet to your own contact form, here is how:
What do you need
1. Customized contact form
2. Wordpress API key
You can get one if you sign up with Wordpress.
3. Akismet Class
You can download it here
The precess
1. Upload akismet.class.php to your plugin folder. (It make sense if you put it under akismet plugin folder.)
2. Include akismet.class.php
Write include ‘akismet.class.php’; (depend where you put your php file)
3. load array with data in contact from
$checkthis = array(
'author' => $name,
'email' => $email,
'website' => $website,
'body' => $message,
);
4. Instantiate an instance of the class
$akismet = new Akismet('http://www.yourdomain.com/', 'YOUR_WORDPRESS_API_KEY', $Checkthis);
5. Check for spam
if($akismet->isSpam()){
header( "Location: $spamurl" );
exit;
}
Ok, now your contact form is protected by Akismet. Here is a sample of how the final php file might look like.
Download Sample Code
About this entry
You’re currently reading “How to make anti-spam contact form with Akismet,” an entry on LinusLin.com
- Published:
- 08.23.07 / 12am
Blogroll
Type your keyword and press Enter

No comments
Leave your Comment | Show Archive