hCaptcha integration | WordPress.org

[ad_1]

Maybe try this?

<?php echo do_shortcode( '[hcaptcha auto="true"]' ); ?>

  • This reply was modified 12 hours, 3 minutes ago by joneiseman.

Thanks for your hint. The result is the same as before. The captcha is not a mandatory field…

Here is, how I solved the problem.

Add hCaptcha to the booking form:

<?php echo do_shortcode( '[hcaptcha]' ); ?>

Add validation into function.php:

function em_validate($result, $EM_Event){ 
	$captcha_result = null;
	
	$captcha_result = hcaptcha_verify_post();
	
	if ( null !== $captcha_result ) {
		$EM_Event->add_error('Bitte löse das Captcha-Rätsel.');
		$result = false;
	}

	if (!is_user_logged_in() && $_REQUEST['user_name'] == ''){
		$EM_Event->add_error('Bitte gib deinen Namen an.');
		$result = false;
	}
		
	if (!is_user_logged_in() && $_REQUEST['user_email'] == ''){
		$EM_Event->add_error('Bitte gib deine E-Mailadresse an.');
		$result = false;
	}	
	
	return $result;	
}
add_filter('em_booking_validate','em_validate', 1, 2);

I hope, this will help others to protect the booking form against spam submissions.

Have fun!
Heiko

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer