I have installed the plugin without any problems. When i enter the wrong word, the error message and the textarea are now in a new blank page. Can anyone help me
Hi Stephane, that is actually the default behavior
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
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:
if ( $securitycode == '' )
{
include (TEMPLATEPATH . '/comments-error.php');
exit();
}
Replace:
// If this row doesn't exist, say something
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 this row doesn't exist, say something
if (is_null($matchthis)) {
include (TEMPLATEPATH . '/comments-expired.php');
exit();
}
if ( strtolower( $matchthis ) != strtolower( $securitycode ) ) {
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: