plugin not working | Peter's Custom Anti-Spam for WordPress | Forum
Back to the custom anti-spam plugin page
Hi Stephane, that is actually the default behavior [Image Can Not Be Found]
If you want some “same page” feedback then you’ll have to do your own JavaScript or Ajax modifications. If you want something like what I do on my site (new page feedback but integrated into the site design), you’ll have to develop some extra templates. I’ve been meaning to create a tutorial on the template workflow, but haven’t gotten around to that [Image Can Not Be Found]
In a nutshell, this is how I created the "friendlier anti-spam" error pages for the plugin on theblog.ca. I don't wish to give specific template instructions because the nuances of the template code would be different for each person's theme.
1. Tweak the way the plugin processes anti-spam word errors
Instead of the die() commands in the plugin, make WordPress load some custom error template files. In wp-content/plugins/custom-anti-spam/custom_anti_spam.php:
Replace:
{
die("<p>{$cas_displaytext['emptyfield']}</p>\\n<p>{$cas_displaytext['copyfield']}</p>\\n<textarea cols=\\"100%\\" rows=\\"10\\" onclick=\\"this.select();\\" readonly=\\"true\\">$commentbody</textarea>");
}
With:
{
include (TEMPLATEPATH . '/comments-error.php');
exit();
}
Replace:
if (is_null($matchthis)) die("<p>{$cas_displaytext['alreadyused']}</p>\\n<p>{$cas_displaytext['copyfield']}</p>\\n<textarea cols=\\"100%\\" rows=\\"10\\" onclick=\\"this.select();\\" readonly=\\"true\\">$commentbody</textarea>");
With:
if (is_null($matchthis)) {
include (TEMPLATEPATH . '/comments-expired.php');
exit();
}
Replace:
{
die("<p>{$cas_displaytext['wrongfield']}</p>\\n<p>{$cas_displaytext['copyfield']}</p>\\n<textarea cols=\\"100%\\" rows=\\"10\\" onclick=\\"this.select();\\" readonly=\\"true\\">$commentbody</textarea>");
}
With:
include (TEMPLATEPATH . '/comments-error.php');
exit();
}
2. Create custom error templates
Create some templates comments-error.php and comments-expired.php. These should contain the comment form from your default theme, the header, sidebar, and footer as required by a full page, and some descriptive error text. If you can get this part right, users are presented with an error page but a blank form.
3. Fill in the error templates' comment form with the posted information.
For each field in your form (name, e-mail address, comment, etc.) print the values of the posted information, so that users don't have to enter their information again. For example, the code for the name field would look like this:
<label for="author"><small>Name <?php if ($req) echo "(required)"; ?></small></label></p>