Sepetim

Sepetinize ürün eklenmemiş :(

Ürünler Hesabım Favoriler0 Whatsapp
<?php
add_action( 'login_form', 'display_recaptcha_on_login' );
function display_recaptcha_on_login() {
echo "<script> function onSubmit(token) { document.getElementById('loginform').submit(); } </script> <button class='g-recaptcha' data-sitekey='6LcTGQYaAAAAAPQmsEScNyoq67Bxu2twz0bM8Ooy' data-callback='onSubmit' data-size='invisible' style='display:none;'>Submit</button>";
}

add_action( 'register_form', 'display_recaptcha_on_register' );
function display_recaptcha_on_register() {
echo "<script> function onSubmit(token) { document.getElementById('registerform').submit(); } </script> <button class='g-recaptcha' data-sitekey='6LcTGQYaAAAAAPQmsEScNyoq67Bxu2twz0bM8Ooy' data-callback='onSubmit' data-size='invisible' style='display:none;'>Submit</button>";
}

add_filter('wp_authenticate_user', 'verify_recaptcha_on_login', 10, 2);
function verify_recaptcha_on_login($user, $password) {
if (isset($_POST['g-recaptcha-response'])) {
$response = wp_remote_get( 'https://www.google.com/recaptcha/api/siteverify?secret=6LcTGQYaAAAAAFELTUVyG0VatKgt0u96AobGTQwD&response=' . $_POST['g-recaptcha-response'] );
$response = json_decode($response['body'], true);
if (true == $response['success']) {
return $user;
} else {
return new WP_Error( 'Captcha Invalid', __('<strong>ERROR</strong>: You are a bot') );
}
} else {
return new WP_Error( 'Captcha Invalid', __('<strong>ERROR</strong>: You are a bot. If not then enable JavaScript.') );
}
}