# Add support for hCaptcha

**URL:** <https://community.hivepress.io/t/add-support-for-hcaptcha/9795>\
**Category:** Feature Requests\
**Tags:** confirmed\
**Created:** [February 19, 2024, 1:53am UTC](https://community.hivepress.io/t/add-support-for-hcaptcha/9795 "2024-02-19T01:53:13Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![GoVegan](https://community.hivepress.io/letter_avatar_proxy/v4/letter/g/65b543/32.png) [@GoVegan](https://community.hivepress.io/u/GoVegan)\
**Post date:** [March 27, 2025, 1:19pm UTC](https://community.hivepress.io/t/add-support-for-hcaptcha/9795/6 "2025-03-27T13:19:25Z")

</div>

Hi Ardain,

Because I couldn’t wait any longer I implemented it myself 😇  
Here are my snippets (UPDATED):

```auto
// Add hCaptcha to user register form
add_filter(
	'hivepress/v1/forms/user_register',
	function( $form ) {
		$form['footer'] = '<div id="my-hcaptcha-box">' . do_shortcode('[hcaptcha]') . '</div>' . hivepress()->helper->get_array_value( $form, 'footer' );
		return $form;
	},
	100
);

// Throw error if hCaptcha is missing
add_filter(
	'hivepress/v1/forms/user_register/errors',
	function( $errors, $form ) {
		$result = \HCaptcha\Helpers\API::verify_request();		

		if ( null !== $result ) {
			$errors[] = 'Please solve the hCaptcha.';
		}		
		
		return $errors;
	},
	100,
	2
);

```

Please note I used the hook ‘hivepress/v1/forms/user\_register’, but I’m sure you can also use ‘hivepress/v1/forms/user\_login’ (did not test it though).

Because the above snippet inserts the hCaptcha below the submit button, I added a jQuery snippet as well, which also moves the form messages for better UX.

```auto
// Move hCaptcha and form messages above submit button
jQuery(document).ready(function( $ ) {
	// Get elements
	const $submitButton = $('#user_register_modal .hp-form__footer button');	
	const $formMessages = $('#user_register_modal .hp-form__messages');
	const $hCaptcha = $('#my-hcaptcha-box');
	
	// Insert elements	
	$hCaptcha.insertBefore($submitButton);
	$formMessages.insertBefore($submitButton);	
	
});

```

Hope this helps!

---

_[View the full topic](https://community.hivepress.io/t/add-support-for-hcaptcha/9795)._
