After a long search to the forum how to implement joomla captcha to the virtuemart enquiry form I have found a solution myself and wanted to share with you.
It is tested with virtuemart 2.0.26a and it is based in the tutorial I found here:
http://blog.plite.org/neo_one2199/2013/04/03/use-joomla-default-recaptcha-plugin-in-your-component-or-module/first we have to enable captcha plugin from plugin manager and fill it with public and private key that we could create from:
http://www.google.com/recaptchaIf you have made template overrides, you have to put the code in the overrided files inside: your_template_name/com_virtuemart/askquestion
in the file: components/com_virtuemart/views/askquestion/tmpl/form.php
after textarea and before submit button we add the code:
<? // captcha addition
JPluginHelper::importPlugin('captcha');
$dispatcher = JDispatcher::getInstance(); $dispatcher->trigger('onInit','dynamic_recaptcha_1');
?>
<div id="dynamic_recaptcha_1"></div>
<? // end of captcha addition
?>
in the file: components/com_virtuemart/views/askquestion/tmpl/mail_confirmed.php
on the top of the page before php tag close we add:
// captcha addition
$post = JRequest::get('post');
JPluginHelper::importPlugin('captcha');
$dispatcher = JDispatcher::getInstance();
$res = $dispatcher->trigger('onCheckAnswer',$post['recaptcha_response_field']);
if(!$res[0]){
$askquestion_url = JRoute::_('index.php?option=com_virtuemart&view=productdetails&task=askquestion&virtuemart_product_id=' . $this->product->virtuemart_product_id . '&virtuemart_category_id=' . $this->product->virtuemart_category_id . '&tmpl=component', FALSE);
die(JText::_('COM_VIRTUEMART_WRONG_CAPTCHA').' <a href="'.$askquestion_url.'">'.JText::_('COM_VIRTUEMART_BACK').'</a>');
}
// end of captcha addition
in the file: language/en-GB/en-GB.com_virtuemart.ini
we add the two new variables:
COM_VIRTUEMART_WRONG_CAPTCHA="The captcha code is wrong, please try again"
COM_VIRTUEMART_BACK="back"
Good luck

Emmanuel
[attachment cleanup by admin]