You are here

function captcha_after_get_captcha_element in CAPTCHA After 7

Same name and namespace in other branches
  1. 6 captcha_after.module \captcha_after_get_captcha_element()

Helper function for finding captcha element in form array.

Return value

boolean Reference to form captcha element or FALSE if if captcha element is not foud in form.

2 calls to captcha_after_get_captcha_element()
captcha_after_form_after_build in ./captcha_after.module
After build state of form. Decide should we skip captcha element validation.
captcha_after_form_pre_render in ./captcha_after.module
Form is in pre rendered state.

File

./captcha_after.module, line 159
Show CAPTCHA protection on selected forms after specified number of unsuccessful form submit attempts has been made.

Code

function &captcha_after_get_captcha_element(&$form) {
  if (isset($form['captcha'])) {
    return $form['captcha'];
  }
  if (isset($form['actions']['captcha'])) {
    return $form['actions']['captcha'];
  }

  // For node forms.
  if (isset($form['buttons']['captcha'])) {
    return $form['buttons']['captcha'];
  }

  // We didn't find captcha element on captcha enabled form - this is a valid
  // case for example when skip captcha protection is configured for some user
  // roles. And we are returing variable here because function needs to return
  // reference.
  $element = FALSE;
  return $element;
}