I do not know how to formulate this exactly, but ATM it is even a kind of issue. So i will give you the example:

Commerce Drupal module has the ability for anonymous users to add products to the shopping card using the "Add to cart widget".
I want to keep this ability but i want to protect it with the CAPTCHA module.
The problem is that the widget has a "form -> select -> options" with a form id that:

  1. depends on the products shown(i.e. is not constant), like: "commerce-cart-add-to-cart-form-10-11" etc. appending at the end products id
  2. when the user changes the selection to another product(for example from product 10 to 11 in the above case), the form id is changed too, as an incrementing index is added to the end every time a change of the selection occurs like: "commerce-cart-add-to-cart-form-10-11--1", "commerce-cart-add-to-cart-form-10-11--2", "commerce-cart-add-to-cart-form-10-11--3" etc. This is done via AJAX and has the bug described in #1395184: Forms with AJAX trigger "CAPTCHA session reuse attack detected." error. I managed the bug using the proposed code changes( isset($form_state['triggering_element']['#value'])), but now it is not showing any capture image on a product change

Anyway... my question is:
Is it possible to implement a new feature, so form ids that will be protected by CAPTCHA, to be able to be added to the protection using wildcards... like in the example above to add(admin/config/people/captcha):
commerce_cart_add_to_cart_form_* -> [default challenge type]
because now CAPTCHA practically cannot be used for protection of the "add to cart widget", and i guess to other custom forms which use ajax and change the form id that is watched by CAPTCHA?

Comments

soxofaan’s picture

Status: Active » Closed (duplicate)

duplicate of #255795: Add CAPTCHA to all forms by default

long story short: wildcards are not supported by CAPTCHA module, but can easily be achieved by a small helper module that implements hook_form_alter() and adds

 $form['my_captcha_element'] = array(
      '#type' => 'captcha',
    );

to the desired forms