registration_role.module in Registration role 5
File
registration_role.module
View source
<?php
function registration_role_help($section = '') {
$output = '';
switch ($section) {
case "admin/modules#description":
$output = t("Auto-assign role at registration.");
break;
}
return $output;
}
function registration_role_menu($may_cache) {
$items = array();
if ($may_cache) {
$items[] = array(
'path' => 'admin/user/registration_role',
'title' => t('Registration role'),
'description' => t('Assign users an extra role at signup.'),
'callback' => 'drupal_get_form',
'callback arguments' => array(
'registration_role_admin_settings',
),
'access' => user_access('administer users'),
);
}
return $items;
}
function registration_role_admin_settings() {
$roles = user_roles(TRUE);
unset($roles['2']);
$form['registration_role_roles'] = array(
'#type' => 'radios',
'#title' => t('Select role to automatically assign to new users'),
'#options' => $roles,
'#default_value' => variable_get('registration_role_roles', ''),
'#description' => t('The selected role will be assigned to new registrants from now on. Be sure this role does not have any privileges you fear giving out without reviewing who receives it.'),
);
return system_settings_form($form);
}
function registration_role_user($op, &$edit, &$user, $category = null) {
if ($op == "insert" && ($rid = variable_get('registration_role_roles', ''))) {
$edit['roles'][$rid] = array();
}
}