Skip to content

Instantly share code, notes, and snippets.

@davidsword
Last active February 8, 2018 21:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidsword/ea04f694983bc4b49e0bf64fb1ac724b to your computer and use it in GitHub Desktop.
Save davidsword/ea04f694983bc4b49e0bf64fb1ac724b to your computer and use it in GitHub Desktop.
Hide the recaptcha field in a gravity form until the user has started entering text.
<?php
add_action( 'wp_footer', 'ds_gf_footer', 99);
function ds_gf_footer() {
?>
<script>
jQuery(window).load(function() {
jQuery('.gform_wrapper').each(function(){
var recaptcha = jQuery(this).find('.ginput_recaptcha');
if (recaptcha) {
recaptcha.parent().hide();
jQuery(this).find('input, textarea').change(function(){
if (recaptcha.parent().css('display') == 'none')
recaptcha.parent().fadeIn()
})
}
})
});
</script>
<?php
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment