jobberBase custom development and support


Code School

reCaptcha on Contact Form

contact-usone of our website has started getting spam messages from bots sending through the contact form, and obviously the easiest way to minimize (if not all together stop) is to just enable reCaptcha on the contact form. by default, jobberBase only has reCaptcha enabled when posting a new job and applying for a job. so here’s how you can implement reCaptcha on the Contact Form as well.

open page_page.php on the root folder and add this before the first line:

$smarty->assign('the_captcha', recaptcha_get_html(CAPTCHA_PUBLIC_KEY));

on the same file, before these lines:

if ($contact_name == '')
	$errors['contact_name'] = $translations['contact']['name_error'];

add this:

// validation
	$resp = recaptcha_check_answer(CAPTCHA_PRIVATE_KEY,
	if (!$resp->is_valid) 
		$errors['captcha'] = $translations['captcha']['captcha_error'];

that should take care of generating the reCaptcha field. and then next, open /_includes/default/page.tpl and before the submit field

<input type="submit" name="submit" id="submit" value="{$}" />

add this block:

<label>Anti-Spam:</label><br />
	<script type="text/javascript">
	  var RecaptchaOptions = {
		theme : 'white',
		tabindex : 9
	{$the_captcha} <span class="validation-error">{if $smarty.session.apply_errors.captcha}
	<img src="{$BASE_URL}_templates/{$THEME}/img/icon-delete.png" alt="" /> {$errors.captcha}{/if}</span>
	<br /><br />
Tagged as: , , , , , ,

1 Comment

Code School

  1. Hi there, I know this is a little old, but I’m trying to add the recaptcha field into the contact form and don’t seem to make it work. I did as above and didn’t see any changes on the form. I was wondering, is there anything I need to do besides those 3 steps? Thanks a lot!

Leave a Response