• Resolved cicopitalia

    (@cicopitalia)


    How to show reCAPTCHA v3 badge only in contact form page? I don’t think there is any need to show it on pages not using reCAPTCHA.

    • This topic was modified 5 years, 11 months ago by cicopitalia.
Viewing 8 replies - 1 through 8 (of 8 total)
  • I would also like to know how to do this. It should only have to be shown on the page with the form.

    Same here! And I only would like to load the script from recaptcha on contact page where contact form 7 is located. It adds approx 200-400ms on the loading times. Which I dont like at all, it is not needed sitewide so why load it site wide!?

    Please note that the V3 ReCaptcha script runs on ALL pages. It is supposed to help Google learn the behavior of spammers. If you poke around in the forum you can find a CSS method for hiding the badge. It is not an option in the plugin.

    The script for Google reCAPTCHA v3 is loaded on all pages for two reasons: 1) it increases the accuracy of the bot versus human score, and 2) CF 7 has not built in a way to know which of your pages have a contact form.

    There is a way to show the badge on only contact pages described here, but if I were you, I’d roll back to version 5.0.5 of CF 7 and go with the v2 reCAPTCHA to avoid the issues with v3 and get the speed back.

    Solution for me:
    add_action(‘wp_print_scripts’, ‘deregister_cf7_script’, 100);
    function deregister_cf7_script()
    {
    if (!is_page(‘contact’)) {
    wp_deregister_script(‘google-recaptcha’);
    }
    }

    Thread Starter cicopitalia

    (@cicopitalia)

    Using “Code Snippets” plugin (that allows you to leave your theme unchanged), I added your code (my contact form page happens to be named “contact”) as a snippet (with option “Run snippet everywhere”) and it seems to work.
    Thanks!

    Please note that this solution will not work if you have contact forms in sidebars. footer, pop-ups, etc.

    Great answer by klimovjet and plugin solution from cicopitalia. Worked for my situation. If you have contact forms in sidebars or pop-ups I would refer to the “I’d like to hide the reCAPTCHA v3 badge. What is allowed?” section of the Google reCAPTCHA FAQ, which states: “You are allowed to hide the badge as long as you include the reCAPTCHA branding visibly in the user flow.”

    There are examples of the branding required on the FAQ.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘How to show reCAPTCHA v3 badge only in contact form page?’ is closed to new replies.