Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.

Differences Between: [Versions 402 and 403]

This is a PHP library that handles calling reCAPTCHA v2. - Documentation {@link https://developers.google.com/recaptcha/docs/display} - Get a reCAPTCHA API Key {@link https://www.google.com/recaptcha/admin} - Discussion group {@link http://groups.google.com/group/recaptcha}

Copyright: 2018 Jeff Webster
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 193 lines (7 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 3 functions


Functions that are not part of a class:

recaptcha_lang($lang = null)   X-Ref
Returns the language code the reCAPTCHA element should use.
Google reCAPTCHA uses different language codes than Moodle so we must convert.
https://developers.google.com/recaptcha/docs/language

param: string $lang Language to use. If not provided, get current language.
return: string A language code

recaptcha_get_challenge_html($apiurl, $pubkey, $lang = null)   X-Ref
Gets the challenge HTML
This is called from the browser, and the resulting reCAPTCHA HTML widget
is embedded within the HTML form it was called from.

param: string $apiurl URL for reCAPTCHA API
param: string $pubkey The public key for reCAPTCHA
param: string $lang Language to use. If not provided, get current language.
return: string - The HTML to be embedded in the user's form.

recaptcha_check_response($verifyurl, $privkey, $remoteip, $response)   X-Ref
Calls an HTTP POST function to verify if the user's response was correct

param: string $verifyurl URL for reCAPTCHA verification
param: string $privkey The private key for reCAPTCHA
param: string $remoteip The user's IP
param: string $response The response from reCAPTCHA
return: ReCaptchaResponse