Dynamic reCAPTCHA Language

The language of the reCAPTCHA is stored as a Ninja Forms setting, which can be dynamically set on page load to accommodate multi-lingual sites or language specific forms.

<?php
/**
* Update the recaptcha_lang setting.
*
* @param string $setting_key
* @param string $new_value
* @param bool $defer_update True will update the value in memeory, but will not update the database.
*/
Ninja_Forms()->update_setting( 'recaptcha_lang', $recaptcha_lang, true );

Example

Change the reCAPTCHA language for the entire site.

<?php
add_action( 'init', function() {
if( true ){ // Some condition to change the language.
$recaptcha_lang = 'en';
Ninja_Forms()->update_setting( 'recaptcha_lang', $recaptcha_lang, true );
}
});

Example Per Form

Change the reCAPTCHA language for a single form.

<?php
add_action( 'nf_get_form_id', function( $form_id ) {
if( '12' == $form_id ) {
$recaptcha_lang = 'en';
Ninja_Forms()->update_setting( 'recaptcha_lang', $recaptcha_lang, true );
}
});