Update reCAPTCHA widget to use “compact” mode.


Filename: gw-compact-recaptcha.php

 * Gravity Wiz // Gravity Forms // Update reCAPTCHA widget to use "compact" mode.
 * https://gravitywiz.com/
// Update "123" to your form ID and "4" to your reCAPTCHA field ID.
add_filter( 'gform_field_content_123_4', function( $field_content ) {
	$search        = 'data-theme=';
	$replace       = sprintf( 'data-size=\'compact\' \0', $field_content );
	$field_content = preg_replace( "/$search/", $replace, $field_content, 1 );
	return $field_content;
} );

Leave a Reply

Your email address will not be published. Required fields are marked *

  • Trouble installing this snippet? See our troubleshooting tips.
  • Need to include code? Create a gist and link to it in your comment.
  • Reporting a bug? Provide a URL where this issue can be recreated.

By commenting, I understand that I may receive emails related to Gravity Wiz and can unsubscribe at any time.