registration_role.module in Registration role 6
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() {
$items = array();
$items['admin/user/registration_role'] = array(
'title' => t('Registration role'),
'description' => t('Assign users an extra role at signup.'),
'page callback' => 'drupal_get_form',
'page arguments' => array(
'registration_role_admin_settings',
),
'access arguments' => array(
'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', ''))) {
$roles = user_roles(TRUE);
$edit['roles'][$rid] = $roles[$rid];
}
}