Arrow

plugin not working | Peter's Custom Anti-Spam for WordPress | Forum

Back to the custom anti-spam plugin page

Please consider registering
guest

Log In

Lost password?
Advanced Search

— Forum Scope —

  

— Match —

   

— Forum Options —

   

Minimum search word length is 4 characters - maximum search word length is 84 characters

Topic RSS
plugin not working
October 15, 2008
9:33 am
Stephane
Guest

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

Stephane

October 15, 2008
2:22 pm
Peter
Admin
Forum Posts: 841
Offline

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]

October 16, 2008
9:40 am
Stephane
Guest

Hi,

i wanted to say that the only part of the page displayed is the error message and the textarea, all other part is absent

Stephane

October 16, 2008
11:18 am
Peter
Admin
Forum Posts: 841
Offline

Hi, yes that is the default behaviour.

October 19, 2008
1:06 am
Peter
Admin
Forum Posts: 841
Offline

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:

if ( $securitycode == '' )
{
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:

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();
}

Replace:

if ( strtolower( $matchthis ) != strtolower( $securitycode ) )
{
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:

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:

<p><input type="text" name="author" id="author" value="<?php print stripslashes(htmlentities($_POST['author'],ENT_QUOTES)); ?>" size="22" tabindex="1" />
<label for="author"><small>Name <?php if ($req) echo "(required)"; ?></small></label></p>