Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save faisalahammad/cfe95a7b236255f91fef083ed3156a32 to your computer and use it in GitHub Desktop.
Save faisalahammad/cfe95a7b236255f91fef083ed3156a32 to your computer and use it in GitHub Desktop.
PHP snippet to fix Google reCaptcha v3 loading issue in Ninja Forms with Elementor Pro. This workaround ensures proper reCaptcha script enqueue using Ninja Forms settings and supports multilingual options. Ideal for WordPress developers facing reCaptcha conflicts between Ninja Forms and Elementor Pro plugins.
<?php
/**
* Fix Google reCaptcha v3 loading issue in Ninja Forms with Elementor Pro.
*
* @author Faisal Ahammad <[email protected]>
*/
add_filter('ninja_forms_pre_enqueue_recaptcha_v3_js', 'nfele_enqueue_recaptcha_v3_js');
function nfele_enqueue_recaptcha_v3_js()
{
$recaptcha_lang = Ninja_Forms()->get_setting('recaptcha_lang', 'en');
$site_key = Ninja_Forms()->get_setting('recaptcha_site_key_3');
wp_enqueue_script(
'nf-google-recaptcha',
'https://www.google.com/recaptcha/api.js?hl=' . $recaptcha_lang . '&render=' . $site_key,
array('jquery'),
'3.0',
true
);
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment