Currently if you use a development or testing environment, there's no way to disable the CAPTCHA validation for that particular environment without some serious hooking.

What we need is a global variable that can be overridden in settings.php for different environments that disable CAPTCHA as a whole so that we can run automated tests that bypass captcha alltogether.

A good example of this is running end-to-end user signup tests without having to manually enter a CAPTCHA code on a testing environment.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

codesidekick’s picture

Status: Needs work » Needs review
FileSize
519 bytes

Attached is a patch with the global override variable.

If you'd like to disable CAPTCHA on your environment you can simply use:

global $conf;
$conf['disable_captcha'] = TRUE;

in your settings.php file (or local.settings.inc file) and it will disable CAPTCHA for the given environment allowing you to run automated tests.

Note:
The captcha widget will still be displayed (useful for theming and assertions) however the validation won't take place (you can enter any or no value).

codesidekick’s picture

Assigned: codesidekick » Unassigned
podarok’s picture

Priority: Normal » Critical
Status: Needs review » Needs work
Issue tags: +Needs documentation

Commited

Good to have a small documentation update related to this, Please do that in follow-up

  • podarok committed 76d0f84 on 7.x-1.x authored by codesidekick
    Issue #2375745 by codesidekick: Environment specific captcha disabling
    
johnennew’s picture

Priority: Critical » Normal
FileSize
456 bytes

I have found that this is not sufficient and had to add the following additional check to prevent the captcha appearing because filling in the field is sometimes still required.

johnennew’s picture

Status: Needs work » Needs review
FileSize
1000 bytes

Please find a better patch including the requested documentation included as well.

dineshw’s picture

Assigned: Unassigned » dineshw
Ashlesha’s picture

Assigned: dineshw » Ashlesha
dineshw’s picture

Assigned: Ashlesha » dineshw

Status: Needs review » Needs work

The last submitted patch, 6: captcha-2375745-6.patch, failed testing. View results

JayKandari’s picture

Assigned: dineshw » Unassigned
Status: Needs work » Needs review
FileSize
1.01 KB

Created a patch inspired from previous patches in this thread. Instead of skipping the whole captcha, we can allow the user to skip certain forms.
Use case: When the user wants to disable captcha on certain forms and to avoid manual deleting & recreating captcha points from the configuration page.

A form can be skipped from settings.php by adding following line.

$conf['skip_captcha_forms'] = ['user_login'];

Suggestions most welcome.
Kindly Review the patch. Thanks !!

Status: Needs review » Needs work

The last submitted patch, 11: 2375745-11-skip-captcha-forms.patch, failed testing. View results

seeni’s picture

#1 worked for me thanks @codesidekick

RgnYLDZ’s picture

How can we disable captcha for a specific form like register form in D8-D9 settings.local.php?

super_romeo’s picture

Like this:
$config['captcha.captcha_point.user_register_form']['status'] = FALSE;