Description

The wpforms_frontend_recaptcha filter is used to alter the default data attributes with Google’s reCAPTCHA.

Parameters

$data
(array) Array of data attributes for reCAPTCHA.
$form_data
(array) Processed form settings/data, prepared to be used later.

Source

wpforms/src/Frontend/Captcha.php

More Information

The filter can be used to alter the default data attributes set when using Google’s reCAPTCHA.

Example

/**
 * Alter default reCAPTCHA data attributes.
 *
 * @link    https://wpforms.com/developers/wpforms_frontend_recaptcha/
 *
 * @param   array  $data       Array of data attributes from Google's reCAPTCHA.
 * @param   array  $form_data  Form data.
 *
 * @return  array
 */

function wpf_dev_invisible_recaptcha_position( $data, $form_data ) {
     
    $type = wpforms_setting( 'recaptcha-type', 'v2' );
    if ( 'invisible' === $type ) {
        $data[ 'badge' ] = 'inline';
    }

    return $data;

}
add_filter( 'wpforms_frontend_recaptcha', 'wpf_dev_invisible_recaptcha_position', 10, 2 );

Reference Articles

How to Change the Position of the v2 Invisible reCAPTCHA Badge