You are here

function botcha_fprocess in BOTCHA Spam Prevention 6.4

Same name and namespace in other branches
  1. 6 botcha.module \botcha_fprocess()
  2. 6.2 botcha.inc \botcha_fprocess()
  3. 6.3 botcha.module \botcha_fprocess()
  4. 7 botcha.module \botcha_fprocess()

Process form callback for BOTCHA form. Using hooking mechanism that is a hack - we want to come in before #process, but our _form_alter() is way too early (we want to let it use cache for all other modules & data). Ideal would be to have #process callback work on the form, but FAPI does not call it on forms, despite the documentation stating that it does. In fact, D6 code needs '#input'=TRUE on the element to get into calling #process callbacks. So we set '#input'=>TRUE on the form when inserting our callback into form['#process'], and it forces the FAPI to call that code path and we get our intercept. Works like a charm!

File

./botcha.module, line 24
BOTCHA - Spam Prevention It modifies forms by adding various botcha's.

Code

function botcha_fprocess($element, $edit, &$form_state, $complete_form) {

  // Prevent caching of the page with BOTCHA elements.
  // This needs to be done even if the BOTCHA will be ommitted later:
  // other untrusted users should not get a cached page.
  global $conf;
  $conf['cache'] = CACHE_DISABLED;

  // This temporarily disables cache (for this page request)
  unset($element['#cache']);
  return $element;
}