Hello.

I'm a Digital Designer, Art Director and Developer. Posts here are largely be about photography, interactive design, the web, advertising and art.

Nasty wordpress hacks: adding CAPTCHA to wp-wall plugin.

Posted: September 27th, 2009 | Author: admin | Filed under: wordpress | Tags: , , , , , , | Comments Off

Hrm.  Just had to add a CAPTCHA to a WP-wall.  So the aim here is to combine si-captcha and wp-wall.  It’s worth noting that both are excellent plugins, which makes messing about with them a lot easier.  It’s a fairly nasty hack, but it works.

1.  Install and activate SI CAPTCHA

Si Captcha is rather cleverly designed to allow WP-wall to work despite it  (without a captcha).  We need to switch this off first:

2.  Delete lines 751 – 754 of si-captcha.php

These ones:

At this point, the wall won’t work – si-captcha looks for the captcha field of the form, which isn’t there.  Yet.

3.  Add the CAPTCHA field to wp-wall plugin.

Add the following to wp-wall-widget.php, which is the ‘add a captcha’ bits of code ripped out of si-captcha.php.  Told you it was nasty.

You can add it anywhere in the form (id wallform), wherever you want the CAPTCHA to show up.

4.  AJAXIFY

This will make the form work the first time we submit it on each page load.  However, one of the nice things about WP-wall is the ajaxiness of the whole thing.  We need to make sure that the CAPTCHA cookie is reset each time a message is posted.  We can do this by telling the captcha to refresh each time the ‘add a message’ section of the wall is shown / hidden.  On line 17 of wp-wall.js, we’re going to add the function that is called when the refresh button is clicked on the si-captcha:

Note that you need to manually set your base url in the above line (where it says ‘THE-BASE-URL).  If you’ve change the name of the $label variable in si-captcha, you’ll also need to change the ’si_image’ bit of “document.getElementById(’si_image’)” to match..

5.   Done.

That’s it.  CAPTCHA added to WP-wall.  Sorry it’s not very neat.  Seems to work, but no doubt other plugins, various settings in the back end editor, etc will break it.


Comments are closed.