Update recaptcha key values using code

Hi there,
I want to programmatically update the recaptcha v3 key values for Gravity forms using theme’s function file or from another plugin. How can I achieve that? Is there any hook for that?

What I want is something like:

if ( $my_condition ) {
update_option( ‘recaptcha_site_key_v3’, $site_value );
update_option( ‘recaptcha_secret_key_v3’, $secret_value );
}

Any help is appreciated.

TIA!

The keys aren’t stored in separate options like that, they are stored with the other add-on settings in an array with gravityformsaddon_gravityformsrecaptcha_settings as the option name.

To change just the keys, I recommend using the constants to define them instead: https://docs.gravityforms.com/wp-config-options/#h-recaptcha-v3

The constants override the values stored in the settings.

Thanks for the quick reply. From the documentation I see these constants need to be defined in wp-config.php, is it possible to define them from within the theme’s function.php or from any other plugin?

You could include them in another file, as long as that file is loaded before WordPress triggers the init action.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.