Last active
February 8, 2018 21:18
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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