For reCAPTCHA v2 it happened to work like this.
Content of recaptchav2.inc.php in assets/snippets/jot/plugins:
<?php
function recaptchav2(&$object,$params){
global $modx;
switch($object->event) {
case 'onBeforePOSTProcess':
$url = 'https://www.google.com/recaptcha/api/siteverify';
$token = isset($_POST['g-recaptcha-response']) ? $_POST['g-recaptcha-response'] : '';
$params = [ 'secret' => 'Secret_key', 'response' => $token, 'remoteip' => $_SERVER['REMOTE_ADDR'] ];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
curl_close($ch);
$response = json_decode($response, true);
if ( $response['success'] == false ) {
$object->form['error'] = 4;
$object->form['confirm'] = 0;
return true;
}
break;
}
}
?>
In JotX call, plugin recaptchav2 goes in &onBeforePOSTProcess
CMS: EVO 1.4.15
PHP: 7.3.33
JotX: 1.1
https://github.com/Temus/JotX/issues/13