Commit 97664ece authored by Steve Gerbino's avatar Steve Gerbino Committed by GitHub

Merge pull request #7 from sgerbino/master

Syncing 7.x-2.x to master
parents 0fb65222 6cb122f3
# Realname registration
Create usernames based on a persons real name, and save those values as user fields.
Tommy Lee Jones → TLJones
The Realname registration module is a solution for forcing professional usernames that are based on a persons real name. The _Username_ on the registration form is replaced with _First name_, _Middle name_ (optional), and _Last name_
fields created and provided by the site builder. The first name, middle name, and last name are preserved in the defined fields, where it is later tokenized for further use.
## Module features
## Configurations
* Use your pre-existing first, middle and last name fields
* A choice of username format
* Force the first letter of last name, middle name, and first name to be capitalized.
* Force the actual username to be lower case. _(This has no effect on the first, middle, and last name field values)_
* Use regex to validate real names
### Integrations
* Profile2 integration (`7.x-2.x`)
* Content profile integration (`6.x-2.x`)
### Tokens
Realname registration provides the following tokens;
* First name & first initial
* Middle name & middle initial
* Last name & last initial
## Recommended modules
* [Profile2](http://drupal.org/project/profile2): Store users real names in profile2 entities, rather than the core profile module. (`7.x-2.x`)
* [Content profile](http://drupal.org/project/content_profile): Store users real names in profile node, rather than the core profile module. (`6.x-2.x`)
* [Realname](http://drupal.org/project/realname): Customize the output of usernames while keeping their login credentials based on their real name.
* [Token](http://drupal.org/project/token): Utilize your users names and initials as tokens.
## Installation
To use this module, you will first need to add name fields to user profiles,
and then configure this module to use them to generate a Drupal user name (the
internal "machine name"). Fields can be added using the contrib module
......
......@@ -181,7 +181,8 @@ function realname_registration_settings_form() {
t('First name, middle name, and last name without spaces (e.g., JohnJacobSmith)'),
t('First name, middle initial, and last name without spaces (e.g., JohnJSmith)'),
t('Last name and first name without spaces (e.g., SmithJohn)'),
t('First name and last initial without spaces (e.g., JohnS)')
t('First name and last initial without spaces (e.g., JohnS)'),
t('First name and last initial with spaces (e.g., John S)')
),
'#required' => TRUE,
);
......
......@@ -341,6 +341,21 @@ function realname_registration_user_presave(&$edit, $account, $category) {
}
break;
case 10:
// Create username based on first name and last initial (e.g., John S).
if (variable_get('realname_registration_use_profile2_firstname_field')) {
$username = $edit['profile_' . $firstname_type][$firstname_field][LANGUAGE_NONE][0]['value'];
}
else {
$username = $edit[$firstname_field][LANGUAGE_NONE][0]['value'];
}
if (variable_get('realname_registration_use_profile2_lastname_field')) {
$username .= ' ' . drupal_substr($edit['profile_' . $lastname_type][$lastname_field][LANGUAGE_NONE][0]['value'], 0, 1);
}
else {
$username .= ' ' . drupal_substr($edit[$lastname_field][LANGUAGE_NONE][0]['value'], 0, 1);
}
break;
}
if (variable_get('realname_registration_tolower')) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment