function spambot_add_form_protection in Spambot 7
Same name and namespace in other branches
- 8 spambot.module \spambot_add_form_protection()
Form builder function to add spambot validations.
Parameters
array $form: Form array on which will be added spambot validation.
array $options: Array of options to be added to form.
1 call to spambot_add_form_protection()
- spambot_form_user_register_form_alter in ./
spambot.module - Implements hook_form_FORM_ID_alter().
File
- ./
spambot.module, line 695 - Main module file.
Code
function spambot_add_form_protection(array &$form, array $options = array()) {
// Don't add any protections if the user can bypass the Spambot.
if (!user_access('protected from spambot scans')) {
// Allow other modules to alter the protections applied to this form.
drupal_alter('spambot_form_protections', $options, $form);
$form['#spambot_validation']['name'] = !empty($options['name']) ? $options['name'] : '';
$form['#spambot_validation']['mail'] = !empty($options['mail']) ? $options['mail'] : '';
$form['#spambot_validation']['ip'] = isset($options['ip']) && is_bool($options['ip']) ? $options['ip'] : TRUE;
$form['#validate'][] = 'spambot_user_register_form_validate';
}
}