Could you please add support for hCaptcha? hCaptcha is better for GDPR compliance than reCaptcha.
Support is easy to integrate for plugin makers according to the hCaptcha plugin authors.
Thank you!
Could you please add support for hCaptcha? hCaptcha is better for GDPR compliance than reCaptcha.
Support is easy to integrate for plugin makers according to the hCaptcha plugin authors.
Thank you!
Hi,
Thanks for your suggestion, weāll consider adding this feature.
Any news about this topic? Indeed hCaptcha is better for gdpr compliance and would much prefer using it over reCaptcha.
Would love to get some instructions on how to go about integrating it for the hivepress login form. You can only turn it on for the wordpress forms where it works, but it is mainly needed for users who come through hivepress login form. I guess you need to make some simple php snippets for it with this hook āhivepress/v1/forms/user_loginā but other than that, any advice would be appreciated? Thank you
Hi Ardain,
Because I couldnāt wait any longer I implemented it myself
Here are my snippets:
// 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_verify_post();
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.
// 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!
@GoVegan Thank you for this! It works wonderfully. This will help many people. Here is the same thing, just for login form for anyone interested.
// Add hCaptcha to user login form
add_filter(
'hivepress/v1/forms/user_login',
function( $form ) {
$form['footer'] = '<div id="login-hcaptcha-box">' . do_shortcode('[hcaptcha]') . '</div>' . hivepress()->helper->get_array_value( $form, 'footer' );
return $form;
},
100
);
// Validate hCaptcha for the login form
add_filter(
'hivepress/v1/forms/user_login/errors',
function( $errors, $form ) {
$result = hcaptcha_verify_post();
if ( null !== $result ) {
$errors[] = 'Please solve the hCaptcha.';
}
return $errors;
},
100,
2
);
And here
// Move hCaptcha and form messages above submit button in the login form
jQuery(document).ready(function( $ ) {
// Get elements
const $submitButton = $('#user_login_modal .hp-form__footer button');
const $formMessages = $('#user_login_modal .hp-form__messages');
const $hCaptcha = $('#login-hcaptcha-box');
// Insert elements
$hCaptcha.insertBefore($submitButton);
$formMessages.insertBefore($submitButton);
});
@Ardain Glad it worked out! And thanks for sharing your snippets as well, this will be useful to others who are looking for the same thing.