Forum Replies Created

Viewing 1 replies (of 1 total)
  • Hi Gil,

    really nice implementation. thanks for that it helped me a lot.

    I know this post is a bit older but I still have the problem that when a user doesn’t fill out the captcha he gets the correct error message but the booking is still written to the database (no confirmation email to the user/admin tho, only a booking in the wordpress backend).

    I am using the normal EM not the pro version and your latest pastebin code.
    Thats the code:

    function my_em_event_form_captcha(){
    ?><p><script src=”https://www.google.com/recaptcha/api.js&#8221; async defer></script><div class=”g-recaptcha” data-sitekey=”6LcD0BUUAAAAAKYRr6xLbT9g5PKmjWb2m7FJU6xl”></div></p><?php
    }
    add_action(’em_booking_form_footer’,’my_em_event_form_captcha’);

    function my_em_event_form_captcha_check($this) {
    global $EM_Booking;

    $captcha;

    if(isset($_POST[‘g-recaptcha-response’])){
    $captcha=$_POST[‘g-recaptcha-response’];
    }

    if(!$captcha){
    $EM_Booking->errors[]=__(‘Bitte bestätigen Sie das Captcha’);
    }
    $secretKey = “XXX”;
    $ip = $_SERVER[‘REMOTE_ADDR’];
    $response=file_get_contents(“https://www.google.com/recaptcha/api/siteverify?secret=&#8221;.$secretKey.”&response=”.$captcha.”&remoteip=”.$ip);
    $responseKeys = json_decode($response,true);
    if(intval($responseKeys[“success”]) !== 1) {
    unset($_REQUEST[’em_tickets’]);
    }
    }
    add_filter(’em_booking_get_post’,’my_em_event_form_captcha_check’,10,$this);

    Thanks for your help 🙂

Viewing 1 replies (of 1 total)