Skip to main content
SnippetsWordpress

Remove reCAPTCHA V3 Badge (2020 update)

By September 8, 2019June 8th, 2020No Comments

UPDATE: I can also hide via CSS like this:

.grecaptcha-badge {
opacity: 0;
}

I stumbled into a situation where I needed to ENABLE captcha on Woocommerce product page(s) and I couldn’t find a workaround using the code below – which still works as intended… This updated code is much better at limiting the reCAPTCHA scripts by looking for CF7 shortcode!

add_action( 'wp_enqueue_scripts', 'custom_load_contact_form_resources', 1 );
function custom_load_contact_form_resources() {
	global $post;

	if ( isset( $post ) && has_shortcode( $post->post_content, 'contact-form-7' ) ) {
		return;
	}

	remove_action( 'wp_enqueue_scripts', 'wpcf7_do_enqueue_scripts' );
	remove_action( 'wp_enqueue_scripts', 'wpcf7_recaptcha_enqueue_scripts' );
}

https://wordpress.org/support/topic/recaptcha-badge-on-all-pages-not-just-pages-with-contact-forms/page/4/#post-12392759

I recently ran into a problem with Contact 7 where excessive spam was coming from our forms. The reCAPTCHA system works great, but includes an annoying albeit lawful little mention that started showing up on ALL pages. This solution will eliminate the mention on pages other than the page in question.

function oiw_load_recaptcha_badge_page(){
    if ( !is_page( array( 'contact','other_pages' ) ) ) {   
        wp_dequeue_script('google-recaptcha');
    }
}
add_action( 'wp_enqueue_scripts', 'oiw_load_recaptcha_badge_page' );
https://ohiwill.com/how-to-remove-google-recaptcha-logo-from-contact-form-7-in-wordpress-hide-recaptcha-badge/

Contact us to learn more about Adopt the Web for your business

Author Jarod Thornton

More posts by Jarod Thornton