• I had to do it for a client and since I saw this was an issue for some people here is a pastebin of my version. Nothing crazy here but I hope it can help people.

    https://pastebin.com/y1qSb7Jy

    If you see something wrong please let me know.

    Enjoy !

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi!
    I added this code in wp-content/plugins/events-manager/templates/forms/bookingform/booking-fields.php, but I got apache2 error message:
    Cannot redeclare my_em_event_form_captcha() (previously declared in /var/www/html/wordpress/wp-content/plugins/events-manager/templates/forms/bookingform/booking-fields.php:13) in /var/www/html/wordpress/wp-content/plugins/events-manager/templates/forms/bookingform/booking-fields.php on line 13

    How to solve this problem?

    Thanks!

    Hi,

    your implementation works Ok on frontend, visitor gets error message, if he skips “I’m not a robot”, but booking is written to database anyway.

    I’m using latest version of EM Pro.

    Any clue?

    Regards.

    Thread Starter Gil-

    (@gil-2)

    Hello,

    @dommgifer you shouldn’t edit the plugin code as when it will be updated your modifications will
    vanish.

    Instead, create your own plugin with your functions.

    @gzzorzz You are right. I’m using the simple version and it wasn’t working.
    I updated the script (I was missing one thing) and it’s now working properly :).

    Check it out : https://pastebin.com/KW9fM73f

    pharzyde

    (@pharzyde)

    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 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Implementation of ReCaptcha 2.0 for Event Manager’ is closed to new replies.