I’m trying to implement a different CAPTCHA into the RSVP form, and to do that, I need to validate that the token matches using the Captcha’s API. If it returns a fail, then I would want to stop and show an error message.
I figured I could create a custom application module that would use the onValidatePublicSubmission handler, but I cannot seem to get it to call.
So far, I have created a file named public.application.mtcaptcha.php and have it saved under ./livewhale/client/modules/mtcaptcha/
This is the code inside:
<?php
$_LW->REGISTERED_APPS['mtcaptcha']=[
'title'=>'MTCaptcha',
'handlers'=>['onValidatePublicSubmission']
];
class LiveWhaleApplicationMtcaptcha {
public function onValidatePublicSubmission($data_type, $id) {
global $_LW;
error_log("Test, onValidatePublicSubmission function called", 0);
$_LW->REGISTERED_MESSAGES['failure'][]='TESTING - this is an automatic failure.';
}
}
?>
I was hoping that this would just make every from fail and reveal my testing error, but this is not the case. I did add error, hoping to see it in the error log, but that didn’t return any results.
So I tried another handler, just to see if my setup is configured correctly. I added onOutput to my module:
...
public function onOutput($buffer) {
global $_LW;
error_log("Test, onOutput function called");
return $buffer;
}
...
This actually added a line to error log, so I feel like the module is somewhat working.
I did play around with changing the name from public to global and private, but they didn’t work either.
Is this the right approach, or am I going in the wrong direction for this type of solution?
Thank you for your time!