Here we are integrating our custom form with magento's default captcha. For example we can add captcha to contactform of Magento
First add captcha block to contacts form and add this code to local.xml
mage/captcha.js contacts 230 50
Go to admin → customers → customer configuration → captcha
On enabling captcha, a forms field will appear as shown below.
Refresh the page so that you can see that contacts page is added to the forms section
Finally call the captcha block in phtml file. Add this code to contact.phtml file
Thats it! we have added captcha to contacts form as shown below.
Captcha in Custom Forms
In some cases we cannot call the “ form.additional.info” as a child block in our phtml file. In that case we can add captcha by calling the singleton to get the capatcha block object in corresponding phtml file.
For eg: if require to add captcha in our custom form say in a “quote” form, follow the steps,
Add the “quote” form under the forms section.
Call the singleton to have the block object of captcha in the phtml file.
Thats it! Captcha will be displayed in “quote” form.
We can reduce the lines in captcha by overriding lib → zend → captcha → Image.php and change the protected $_dotNoiseLevel and protected $_lineNoiseLevel values.