You are here

function username_check_callback in Username originality AJAX check 7

Same name and namespace in other branches
  1. 8 username_check.unique.inc \username_check_callback()
  2. 5 username_check.module \username_check_callback()
  3. 6 username_check.unique.inc \username_check_callback()

Main AJAX function: originality check menu callback.

1 string reference to 'username_check_callback'
username_check_menu in ./username_check.module
Implementation of hook_menu().

File

./username_check.unique.inc, line 11
AJAX callbacks for the username_check module.

Code

function username_check_callback() {
  $output = array();
  $username = $_GET['username'];
  $ret = user_validate_name($username);
  if ($ret) {
    $output['allowed'] = FALSE;
    $output['msg'] = $ret;
  }
  else {
    $ret = user_is_blocked($username);
    if ($ret) {
      $output['allowed'] = FALSE;
      $output['msg'] = t('The username %username is not allowed.', array(
        '%username' => $username,
      ));
    }
    else {
      $username = check_plain($username);
      $ret = _username_check_is_user_exists($username);
      if ($ret) {
        $output['allowed'] = FALSE;
        $output['msg'] = t('The username %username is already taken. If this is you, please ' . l('login,', 'user') . ' or if you\'ve forgotten your password, ' . l('request a new password', 'user/password') . '.', array(
          '%username' => $username,
        ));
      }
      else {
        $output['allowed'] = TRUE;
      }
    }
  }
  drupal_json_output($output);
}