Forums / Cotonti / Support / Captcha + pages

Trustmaster
#34710 2012-06-17 06:31

You need to add the captcha with a plugin. This normally consists of two parts.

The first is displaying the captcha tags, e.g. using 'page.add.tags' hook:

$t->assign(array(
	'PAGEADD_FORM_VERIFYIMG' => cot_captcha_generate(),
	'PAGEADD_FORM_VERIFYINPUT' => cot_inputbox('text', 'rverify', '', 'size="10" maxlength="20"'),
));

Then you need to verify what a user enters, e.g. in 'page.add.add.error' hook:

$rverify = cot_import('rverify', 'P', 'TXT');

if (!cot_captcha_validate($rverify))
{
	cot_error('captcha_verification_failed', 'rverify');
}

Normally you'd want to check that only for guests, so put it inside an if:

if ($usr['id'] == 0)
{
	// captcha code here
}
May the Source be with you!