Contact Form 7 : recaptcha reset not working
Contact form 7 is widely used plugin for wordpress websites. In the same manner recaptcha is also widely used for implementing captcha with contact forms. Combination of both will be a perfect form for wordpress websites. Now a days the contact form 7 recommend to use recaptcha in spite of really simple captcha. Recaptcha is service of google which is highly recommended by contact form 7.
Sometimes working with both of them we find a issue of resetting captcha after form submission. Recently I have faced this issue while working on a website and finally resolved it. Now I am sharing the solution here.
We just need to use a already defined function to reset or reload recaptcha that is :
But the above is only for previous version of recaptcha, now we can use the below one for latest version:
So, we can reset or reload the captcha using the predefined functions. Now, I am discussing here to use them in a better way with wordpress contact form 7 plugin. As we know we have additional setting area in contact form 7 at the edit screen of particular contact form. Just look at the image in this post, that image will guide you the exact location.
http://workroom.ca/feed-goal.php Go to admin=> Contact => Edit Contact form => Additional Settings
Just go to that location and paste the below mentioned code :
DONE with the code, now check your recaptcha will behave as per your requirement.
Just look at the above code, it is using “on_sent_ok” which is a very useful hook for contact form 7. We can use it in so many different ways to change the behavior of our contact forms. To call a function after form submit we generally use this hook.
Here we are using this hook to call “grecaptcha.reset();” function which will reset the captcha just after the form submission.
If you are facing more problems with the recaptcha option or not want to use it in that case you can opt another captcha option for contact form 7 that is really simple captcha. Now a days contact form 7 does not recommend to use really simple captcha so it removes “captcha” option from the admin but other configurations are still there.
This may help someone 🙂