function username_check_callback in Username originality AJAX check 5
Same name and namespace in other branches
- 8 username_check.unique.inc \username_check_callback()
- 6 username_check.unique.inc \username_check_callback()
- 7 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.module, line 91 - Checks user name availability on registration page.
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 = drupal_is_denied('user', $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 name %username is already taken.', array(
'%username' => $username,
));
}
else {
$output['allowed'] = TRUE;
$output['msg'] = t('The username %username is available.', array(
'%username' => $username,
));
}
}
}
drupal_page_header();
print drupal_to_js($output);
exit;
}