1. Home
  2. Docs
  3. Developer Guide
  4. Miscellaneous and Snippet...
  5. Add Captcha To Property Enquiry Form

Add Captcha To Property Enquiry 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_property_enquiry_form_fields', 'add_captcha_to_enquiry_form', 10, 1 );
function add_captcha_to_enquiry_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?