1. Home
  2. Docs
  3. Add-Ons
  4. Send To Friend
  5. Adding a ReCAPTCHA field to the form

Adding a ReCAPTCHA field to the form

We support Google reCaptcha v2 and v3 API keys and hCaptcha.

Once you've obtained your API keys you can simply add the following to your theme's functions.php file:

add_filter( 'propertyhive_send_to_friend_form_fields', 'add_captcha_to_send_to_friend_form', 10, 1 );
function add_captcha_to_send_to_friend_form( $fields )
{
    // Google reCaptcha v2
    $fields['recaptcha'] = array(
        'type' => 'recaptcha',
        'site_key' => 'your-key-here',
        'secret' => 'your-secret-here',
    );

    // Google reCaptcha v3
    $fields['recaptcha'] = array(
        'type' => 'recaptcha-v3',
        'site_key' => 'your-key-here',
        'secret' => 'your-secret-here',
    );

    // hCaptcha
    $fields['hCaptcha'] = array(
        'type' => 'hCaptcha',
        'site_key' => 'your-key-here',
        'secret' => 'your-secret-here',
    );

    return $fields;
}
Was this article helpful to you? No Yes

How can we help?