Hi again!!
This is all great - but I’ve hit a slight snag.
If I create more than one ‘quiz’ on a site, the snippet prevents the owner of the email address from playing ALL quizzes (Not just the one that they have played).
Is it possible to use the ID of the form to limit submissions JUST to that form?
In Formit, each form has a Name which is automatically generated by Formit using the ID of the last page that was submitted before it’s saved to the database (e.g. form-240 - 240 is the resource ID of the page which submitted the data).
<?php
$modx->addPackage('formit', $modx->getOption('core_path').'components/formit/model/');
$email = $hook->getValue('email'); //play with this email, put here emails that occur for the first time or those that are already in the database
$formName = $modx->getOption('formName', $scriptProperties, '');
if($modx->getCollection('FormItForm',array('values:LIKE' => "%$email%", 'form' => $formName))){
$modx->log(xPDO::LOG_LEVEL_ERROR, 'Email exists', '', 'yourCustomHook');
return false;
}
$modx->log(xPDO::LOG_LEVEL_ERROR, 'There are no such emails', '', 'yourCustomHook');
return true;