• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

RocketGeek

Home of WP-Members, The Original WordPress Membership Plugin

  • WordPress Plugins
    • WP-Members
      • FAQs
      • Quick Start
      • Documentation
      • Extensions
    • Advanced Options
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • Download Protect
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • Invite Codes
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • MailChimp Integration
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • PayPal Subscriptions
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • Salesforce Web-to-Lead
    • Security
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • Text Editor
      • Purchase the Plugin
      • Get the Pro Bundle
    • User List
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • User Tracking
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • Memberships for WooCommerce
    • WordPass
  • Blog
    • Basics
    • Tips and Tricks
    • Filters
    • Actions
    • Code Snippets
    • Shortcodes
    • Design
    • Release Announcements
  • Store
    • Cart
    • Checkout
  • Contact
  • Log In
  • Show Search
Hide Search
Home » Plugins » WP-Members » Documentation » API Functions » WP_Members_Captcha

WP_Members_Captcha

Description

The WP_Members_Captcha object class has a number of functions that you may call statically in order to implement custom instances of the captchas supported by WP-Members.  This includes the following captcha types:

  • Google reCAPTCHA v2 (API key required)
  • Google reCAPTCHA v3 (API key required)
  • Really Simple CAPTCHA (Really Simple CAPTCHA plugin required)
  • hCaptcha (API key required)

Methods

There are two methods required to implement one of the captchas – one to display the captcha, the other to validate that it passed.

show()

The show() method is used to display the captcha using the following parameters:

$type  The type of captcha being displayed. Required (recaptcha_v2|recaptcha_v3|rs_captcha|hcaptcha)

$key  The “public” key for the captcha being displayed. For reCAPTCHA, this is your public API key, for hCatpcha it is your API key. This parameter is omitted for Really Simple CAPTCHA.

Return value is a string of HTML for the captcha being displayed.

validate()

The validate() method is used to validate form submission and make sure the captcha was passed.

$type The type of captcha being used. Required (recaptcha_v2|recaptcha_v3|rs_captcha|hcaptcha)

$key The “private/secret” key for the captcha being displayed. For reCAPTCHA, this is your private API key, for hCatpcha it is your secret key. This parameter is omitted for Really Simple CAPTCHA.

Return value is a true|false boolean

Usage

/**
 * To display a captcha, use the show() method passing both the 
 * captcha type (see docs) and your public api key. The method
 * returns a string that you can either append to your form 
 * string or echo/print, depending on what hook you are using
 * to display it.
 */
 $html = WP_Members_Captcha::show( $type, $public_key );
 
 
 /**
  * To validate a captcha upon form submission, use the validate()
  * method passing both the captcha type (see docs) and your 
  * private/secret api key. This returns a true|false boolean.
  */
 $passed = WP_Members_Captcha::validate( $type, $private_key );

Notes

  • Really Simple CAPTCHA requires that you have the Really Simple CAPTCHA plugin installed and activated.
  • Really Simple CAPTCHA does not use an API key for display or validation, so omit the second argument of the method.

Changelog

  • Introduced in WP-Members 3.3.5

Source

The WP_Members_Captcha static methods are in /includes/class-wp-members-captcha.php

  • Getting Started
  • Recommended WordPress® Settings
  • Plugin Settings
    • Options
    • Fields
    • Dialogs
    • Emails
    • New Feature Settings
  • Managing Content
    • Restricting Posts
    • Restricting Pages
    • Show Excerpts
    • Custom Post Types
  • Managing Users
    • Import Users
    • Export Users
    • Edit Users
    • Search Users
  • Login
  • Registration
    • Choosing Fields
    • Create a Registration Page
    • Moderating Registration
    • Using CAPTCHA
    • Removing Registration Options
  • User Profile
  • Memberships
    • Membership Properties
    • Membership Levels
  • Menus
    • Individual Menu Items
    • Logged In Menus
    • Login/Logout Menu Link
  • Customizing Emails
    • Email Address
    • Email Content
    • Email Format
    • Email Shortcodes
    • Email Troubleshooting
  • Customizing Forms
    • Create a Custom Stylesheet
    • Using the WordPress Customizer
    • Login Form HTML
    • Registration Form HTML
    • Widget Login Form HTML
  • Translation and Localization
    • Maintain a custom translation file
    • Filter untranslated strings
    • Multi-language Considerations
  • Shortcodes
    • Pages and Forms
    • Login Status
    • User Fields
    • Memberships
    • Email
    • Other Shortcodes
  • WP-CLI Commands
  • API Functions
  • Filter Hooks
  • Action Hooks
  • FAQs
    • Email troubleshooting
    • Passwords are not being included in Emails
    • The plugin isn’t blocking my content
    • Are files protected?
    • How can I prevent registration spam?
    • How to add a shortcode
    • How to apply login redirects
    • Why can’t users log in?
    • Why does reCAPTCHA v3 fail?
    • Troubleshooting Really Simple Captcha
    • Why do I get a 403 error?
    • How do I use code snippets?
    • My changes aren’t showing up
    • How to hide the “Admin Bar”
    • How to add a forgot password link
    • Password reset doesn’t show any fields
    • Domain not included in the password reset link
    • There was an error processing the form
    • Hidden vs. Restricted
  • Demo Videos
  • How to Request Support
  • Copy Settings for Support
  • Hosting Recommendations

Ready to get started?

Join Today!

© 2025 · butlerblog.com · RocketGeek is built using WordPress, WP-Members, and the Genesis Framework

  • butlerblog.com
  • WP-Members Support Subscription
  • Terms of Service
  • Privacy Policy
  • Refund Policy