You are here

function _login_security_valid_user in Login Security 7

Same name and namespace in other branches
  1. 6 login_security.admin.inc \_login_security_valid_user()

Verify that element is a valid username.

1 string reference to '_login_security_valid_user'
login_security_admin_settings in ./login_security.admin.inc
Build a form body for the configuration settings.

File

./login_security.admin.inc, line 208
login_security.menu.inc

Code

function _login_security_valid_user($element, &$form_state) {
  if ($element['#value'] !== '') {
    $count = db_select('users', 'u')
      ->condition('name', $element['#value'])
      ->countQuery()
      ->execute()
      ->fetchField();
    if (intval($count) != 1) {
      form_error($element, t('The @field field should be a valid username.', array(
        '@field' => $element['#title'],
      )));
    }
  }
}