got a working solution,
but wordpress first validate the username or email address then my validation takes place..
I have used allow_password_reset
filter instead of lostpassword_post
action:
add_filter( 'allow_password_reset', 'my_password_reset_helper' );
function my_password_reset_helper($true)
{
if (isset($_POST['g-recaptcha-response'])) {
$array = array('response' => $_POST['g-recaptcha-response'],
'userip' => $_SERVER['REMOTE_ADDR'],
'secret' => 'asddfer345gfdg4veg45y34635345');
$result = gcaptcha($array);
if (!$result) {
return new WP_Error('denied',
'<strong>ERROR</strong>: Verification Failed.');
}
return $true;
}
return $true;
}