function realname_registration_user in Realname registration 6
Same name and namespace in other branches
- 6.2 realname_registration.module \realname_registration_user()
Implementation of hook_user().
File
- ./
realname_registration.module, line 66 - For using real names during registration/
Code
function realname_registration_user($op, &$edit, &$account, $category = NULL) {
if ($op == 'validate') {
if (isset($edit['name'])) {
if ($edit['name'] == 'unset_username') {
// Generate the username based on first name and last name fields.
$first_init = drupal_substr($edit['firstname'], 0, 1);
$lastname = $edit['lastname'];
$username = strtolower($first_init . $lastname);
$original_username = $username;
$i = 0;
// Check if the username already exists in the database.
while (db_result(db_query("SELECT COUNT(*) FROM {users} WHERE name = '%s';", $username))) {
$username = $original_username . ++$i;
}
$edit['name'] = $username;
}
}
}
}