I have several inputboxes and no textareas in my custom content type. Can I use Akismet that comes with WP for that? If I can, how to do that?
E.g. If I have 5 inputboxes like: name, address, city, telephone, email in my form that is saved from the front page and is used for further processing.
How to use Akismet on that? Is it possible?
if the names of the inputbosex are: name, address, city, telephone and emai, how would you set up the Akismet plugin. What should be done so no spams are saved in my db? (I need to filter the data before being saved to data using akismet in my function in functions.php. So if I get the values like e.g.
$name = $_POST['name'];
$name = $_POST['address'];
$name = $_POST['city'];
$name = $_POST['telephone'];
$name = $_POST['email'];
// here I need if condition to use akismet database to redirect back to the post without executing the rest of my code in my function.
How to do such condition using the Akismet plugin that comes with WordPress?
Akismet – libraries:
First I want to mention that there are many Akismet libraries out there:
http://akismet.com/development/
and here are the API documents:
http://akismet.com/development/api/
Akismet – WordPress plugin:
But as I understand it, you want to use the Akismet WordPress plugin as your library.
The following code snippet is a simple proof of concept, based on the Akismet plugin:
where I use the
akismet_http_post
function to post the data to the Akismet servers.According to the API docs, the following parameters are required:
and one should be careful regarding the spelling of the
referrer
parameter 😉Other useful Akismet functions are for example:
The response I got when testing a real spam comment, was like this:
with the positive (true) spam result.
The next step would be to modify this into a usable function or a class.
Since you’re using some custom form fields, I think you could map them like this:
I don’t think that akismet is the right tool for you. The way akismet works relies on analyzing the content of millions of comments and detect spamming patterns, but the content of your form is not similar to comments and therefor the analyze will be worthless. The only thing akismet can do with you code is to check for known samming IP addresses, something that you can do with other services like the honeypot project which might be a better alternative since you need to pay for using akismet on any commercial site.
Remember that with akismet you also need to decide what do you do when it flags something as spam. The default behavior of the plugin is to keep the comments in the DB in order for a human to be able to check them for false positives. To mimic that you will need to keep your forms in the DB as well even if they where flagged as sam but you will need to develop new UI for it.
There is a simpler solution which might be even more effective then using akismet, just use JS to inject an hidden input with a known value to the form and validate the value when handling the submition on the server side. if validation fails then the form is probably spam.
If you are worried about people that don’t use JS not being able to send the form, you can always add a notice that JS should be enabled to send the form to your form, and hide it in JS.
Most spambots right now don’t parse and execute JS therefor this should be a very good way to stop spam.