We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22683
    • 41 Posts
    Hello, how to use captcha in snippet? huh

    can i use default captcha modx for my snippet? how to use it..

      • 28042 ☆ A M B ☆
      • 24,524 Posts
      There are several snippets that use the default MODx captcha mechanism; webLogin and eForm are two that come to mind. If you look at the code in the assets/snippets/eform/eform.inc.php file and do a search for "veriword", you’ll see how it’s done. The captcha form is set up around line 566:
      	// set vericode
      	if($vericode) {
      		$_SESSION['eForm.VeriCode'] = $fields['vericode'] = substr(uniqid(''),-5);
      		$fields['verimageurl'] = $modx->config['base_url'].'manager/includes/veriword.php?rand='.rand();
      	}
      

      and the submission is validated around line 172:
      		# check vericode
      		if($vericode) {
      			//add support for captcha code - thanks to Djamoer
      			$code = $_SESSION['veriword'] ? $_SESSION['veriword'] : $_SESSION['eForm.VeriCode'];
      			if($fields['vericode']!=$code) {
      				$vMsg[count($vMsg)]=$_lang['ef_failed_vericode'];
      				$rClass['vericode']=$invalidClass; //added in 1.4.4
      			}
      		}
      
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 22683
        • 41 Posts
        Ok thanks Susan Ottwell, now i can use default MODx captcha.. after i learn at your code in a few day.... hehehe laugh