So far I have completed adding google recaptcha on contact page, login page, and pages that has forms on the front end, all are working great as expected.
now only one page is remaining for me to add google recaptcha that is when user clicks on lost your password? link, so I tried adding:
add_action('lost_password', 'my_reset_password');
with the above action added I can see the google captcha on top left corner at the generate new password page, but I want it below the username and email field.
and after that how can I validate the google recaptcha when user clicks on generate new password button. I am new to wordpress, please help. thanks in advance.
I am using latest WordPress version,
~UPDATE~
(now tried the below, but its not validating my captcha, and sending the email with reset link)
add_action('lostpassword_form', 'my_reset_password_field');
function my_reset_password_field() {
?>
<script src='https://www.google.com/recaptcha/api.js'></script>
<p>
<label for="google-captcha">Verify, you are human?</label>
<div style="overflow: hidden" class="g-recaptcha" data-sitekey="asdaasdasdasdasdasdasdasdasd"></div>
</p>
<br>
<?php
}
add_action('lostpassword_post', 'validate_lost_password');
function validate_lost_password() {
if (isset($_POST['g-recaptcha-response'])) {
$array = array('response' => $_POST['g-recaptcha-response'], 'userip' => $_SERVER['REMOTE_ADDR'],
'secret' => '456456gdfgdfgertegdfgdfg');
$result = gcaptcha($array);
if (!$result) {
global $errors;
$errors->add('invalid', '<strong>ERROR</strong>: Verification Failed.');
}
}
}