Enable Google Recaptcha On MediaWiki Create & Edit Page Options

By default recapcha is only shown when MediaWiki users try to create new account, add URL or attempt bad login. In this lesson you will learn how to extend this functionality and enable recaptcha on creation of new pages, page edits and logins etc.

First thing you need to do is read this lesson to activate recaptcha on your MediaWiki website. You should know that there are five “triggers” on which captchas can be displayed in MediaWiki:

  • ‘Edit’ – triggered on every attempted page save
  • ‘Create’ – triggered on page creation
  • ‘Addurl’ – triggered on a page save that would add one or more URLs to the page
  • ‘Createaccount’ – triggered on creation of a new account
  • ‘Badlogin’ – triggered on the next login attempt after a failed one.

Badlogin trigger requires $wgMainCacheType to be set to something other than CACHE_NONE in your LocalSettings.php, if in doubt then this will always work:

$wgMainCacheType = CACHE_ANYTHING;

Default values for these triggers are:

$wgCaptchaTriggers['edit']          = false; 
$wgCaptchaTriggers['create']        = false; 
$wgCaptchaTriggers['addurl']        = true; 
$wgCaptchaTriggers['createaccount'] = true;
$wgCaptchaTriggers['badlogin']      = true;

These values can be changed, open your LocalSettings.php file located in your MediaWiki’s root directory and paste the given code changing set ‘false’ to ‘true’:

$wgCaptchaTriggers['edit']          = true; 
$wgCaptchaTriggers['create']        = true; 
$wgCaptchaTriggers['addurl']        = true; 
$wgCaptchaTriggers['createaccount'] = true;
$wgCaptchaTriggers['badlogin']      = true;

This will enable captcha on edit and create page sections.

In next coming lessons, you will also learn about skipping captchas for user groups or enforcing it to selective user roles on your MediaWiki website.

Leave a Reply

Your email address will not be published. Required fields are marked *