gform_recaptcha_callback

Description

The “gform_recaptcha_callback” JavaScript filter in Gravity Forms allows a custom callback function to be executed when the user successfully submits the captcha.

Usage


gform.addFilter( 'gform_recaptcha_callback', function( callback, elem ) {
	
	callback = function() {
		//do stuff...
		console.log( 'recaptcha executed' );
	};

	return callback;
} );

Parameters

  • callback string or function

    The name of the callback function or the function object to be executed when the user successfully submits the captcha.

  • elem object

    The jQuery object containing the div element with the ginput_recaptcha class for the current reCaptcha field.

Example

1. Add the script via the gform_pre_render hook


add_action( 'gform_pre_render', 'set_callback' );
function set_callback( $form ) {
	?>
	<script type="text/javascript">
		gform.addFilter( 'gform_recaptcha_callback', function( callback, elem ) {

			callback = function() {
				//do stuff...
				console.log( 'recaptcha executed' );
			};

			return callback;
		} );
	</script>
	<?php

	//return the form object from the php hook
	return $form;
}

Placement

Your code snippet should be placed in the functions.php file of your active theme.

Source Code

This filter is located in the function renderRecaptcha() in gravityforms/js/gravityforms.js