Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Contact form 7 : how to change language of recaptcha in wordpress

We are using contact form 7 for forms in wordpress very frequently. As we know if we are preparing a form then we will definitely add a captcha to that form. So, for adding captcha in contact form 7 we choose Recaptcha which is a google service.

Now, in case when we are preparing a website other than the English Language using both of the plugins than we face a issue of recaptcha translation. Normally recaptcha is in English language by default.
lang change
In this case, we have added a contact form 7 plugin and recaptcha plugin. Now we want to change the language of recaptcha with out modifying the plugin core files. To do this just take a example language that is Spanish for now. Now we want to show our recaptcha will show in Spanish language.

Just open the functions.php file of your current theme and paste the below mentioned code :

function wptricks24_recaptcha_scripts() {
		wp_deregister_script( 'google-recaptcha' );

		$url = '';
		$url = add_query_arg( array(
			'onload' => 'recaptchaCallback',
			'render' => 'explicit',
		 	'hl' => 'es'), $url ); // es is the language code for Spanish language

		wp_register_script( 'google-recaptcha', $url, array(), '2.0', true );

	add_action( 'wpcf7_enqueue_scripts', 'wptricks24_recaptcha_scripts', 11 );

After putting the above code as explained above, our recaptcha will be in Spanish language. All the recaptcha options will automatically converted into Spanish language.

Now we can modify it to any of the language, just look at the above code we are using ‘hl’ => ‘es’ where “es” is the language code for Spanish language. We can create this recaptcha with few more languages at a time by applying the conditions to the code. We just need to pass the language code of our choice to “hl” parameter.

If you are facing reloading issue with recaptcha check here : recaptcha reset not working.

The post Contact form 7 : how to change language of recaptcha in wordpress appeared first on Wordpress Tricks.

This post first appeared on WPTricks24 - Wordpress Development Solutions, please read the originial post: here

Share the post

Contact form 7 : how to change language of recaptcha in wordpress


Subscribe to Wptricks24 - Wordpress Development Solutions

Get updates delivered right to your inbox!

Thank you for your subscription