Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

How to implement Google reCaptcha without installing a plugin?

you can use this function i think it works properly.

  add_filter( 'wp_authenticate_user', 'verify_recaptcha_on_login', 10, 3 );
function verify_recaptcha_on_login($user, $password) {
    $secretkey = "your secret key";
    if (isset($_POST['g-recaptcha-response'])) {
    $response = wp_remote_get( 'https://www.google.com/recaptcha/api/siteverify?secret=".$secretkey."&response=" . $_POST["g-recaptcha-response'] );

    $response = json_decode($response['body'], true);


    if (true == $response['success']) {


    return $user;


    } else {


    // FIXME: This one fires if your password is incorrect... Check if password was incorrect before returning this error...


     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.') );


    }
}

Related Posts:

  1. Can I programmatically login a user without a password?
  2. What is $interim_login?
  3. Adding extra authentication field in login page
  4. What exactly is ReAuth?
  5. Login members using web services
  6. Disable WordPress 3.6 idle logout / login modal window / session expiration
  7. How to pass users back and forth using session data?
  8. Need to execute a cron job
  9. Integrate recaptcha and wp_signon – what is needed?
  10. how to update current logged user username
  11. Validate Custom Login field
  12. Calling wp_signon doesn’t log the user in
  13. Is it possible a one click user registration with Facebook or Twitter (or other Social Networks)?
  14. Are there ways of logging in that bypass wp-login.php altogether?
  15. How to display username and password after registration
  16. Two factor authentication
  17. How to generate “WP_Error” Object for user login?
  18. Allow Access to Home Page and Login Screen but Nothing Else (unless logged in)
  19. Where is the php file, that does the checks for login information?
  20. I want login using email not username wordpress front end
  21. Reloading page with a query string upon login for admins
  22. WordPress authentication using custom php?
  23. authenticate user without redirecting
  24. Multiple issues with Ajax login function due to browsers and cookies
  25. Allow login only for one account from one device
  26. How to post frontend login form to a different authentication script from wp-login?
  27. Custom user roles are unable to login
  28. Using WordPress login for a non word-press website
  29. Extend Cookie with auth_cookie_expiration not working
  30. How to use google api for wordpress login
  31. Can we start session from another php site to wordpress blog site?
  32. Opening protected page with cookie?
  33. Handle POST request sent from an external site for login?
  34. External Authentication
  35. Unable to login after adding ReCaptacha without API key
  36. Login and register by API
  37. In Django, how do I know the currently logged-in user?
  38. Can’t log in: “ERROR: Cookies are blocked or not supported by your browser. You must enable cookies to use WordPress.”
  39. Is there any way to rename or hide wp-login.php?
  40. How to login with email only no username?
  41. How can I redirect user after entering wrong password?
  42. Increase of failed login attempts, brute force attacks? [closed]
  43. Login page ERROR: Cookies are blocked due to unexpected output
  44. Separate registration and login for different roles
  45. SSO / authentication integration with external ‘directory service’
  46. Preventing session timeout
  47. How reduce wordpress login session timeout time?
  48. How to prefill WordPress registration with social details
  49. Check for correct username on custom login form
  50. How to Change the Default Home Page for the WordPress Dashboard?
  51. Disallow user from editing their own profile information
  52. I can’t access my site via wp-admin
  53. ‘Password field is empty’ error when using autofill in Chrome
  54. Removing username from the ‘wordpress_logged_in’ cookie
  55. How to show ‘login error’ and ‘lost password’ on my template page?
  56. How do I require authorization / login to view a specific set of posts / pages?
  57. Custom login form
  58. How to prefill the username/password fields on the login page
  59. wp_signon returns user, but the user is not logged in
  60. Prevent wp_login_form() from redirecting to wp-admin when there are errors
  61. Redirect user using the ‘wp_login_failed’ action hook if the error is ’empty_username’ or ’empty_password’
  62. wp_signon() does not authenticate user guidance needed
  63. What are the differences between wp_users and wp_usermeta tables?
  64. WordPress auto login after registration not working
  65. Make my wordpress blog remember my login “forever”
  66. How to check in timber if user is loggedin?
  67. How do I change the language of only the login page?
  68. Stop WordPress from logging me out (need to keep me logged in)
  69. Woocommerce registration page [closed]
  70. How to disable autocomplete on the wp-login.php page
  71. Share login data/cookies between multiple installations
  72. Synchronize WordPress user accounts across multiple domains and installations without using WordPress MU
  73. How do I change the logo on the login page?
  74. Why does WordPress hide the reset password key from the URL?
  75. Is it possible to sign in with user_email in WordPress?
  76. How to use current_user_can()?
  77. Avoid to load default WP styles in login screen
  78. WordPress registration message
  79. How to fake a WordPress login?
  80. how to display the wordpress login and register forms on a page?
  81. Does wp_logout_url() destroy a session? (Logging out question)
  82. How can I send a welcome email to a user AFTER they login for the first time?
  83. Can not login with correct username and password
  84. Custom ReCaptcha Login
  85. Website Visible only to Registered users
  86. How can i increase the login expiration length?
  87. How do I use add_action from a class method?
  88. How to remove the WordPress logo from login and register page?
  89. How can I add a custom script to footer of login page?
  90. Brute force attack?
  91. Customize wp_new_user_notification_email()
  92. How to check WordPress website username and password is correct
  93. Login email after registration never sent or received
  94. How can I create a separate blog that is private?
  95. How to keep always logged in development environment
  96. Add Confirm Password field in wp-login.php Password Reset page
  97. Log in from one wordpress website to another wordpress website
  98. Stop users from logging in from multiple locations
  99. I want to disable E-Mail verifcation / activation when a user signs up for my WordPress site
  100. custom login page redirect to logged in user profile page
Categories login Tags authentication, captcha, code, google, login
Pending Custom Link in Menu
how to get the comment ID in the front end when the REPLY button is clicked?

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress