function select_registration_roles_form_user_register_form_alter in Select registration roles 7
Implements hook_form_user_register_form_alter().
File
- ./
select_registration_roles.module, line 72 - Admin can select roles that will be display on registration form.
Code
function select_registration_roles_form_user_register_form_alter(&$form, &$form_state) {
$roles = array();
$display_roles = array_filter(variable_get('select_registration_roles_setby_admin', $roles));
if (empty($display_roles)) {
$form['select_roles'] = array(
'#type' => 'checkboxes',
'#title' => t('You must configure <a href = "@configure">role field on the registration form.</a>', array(
'@configure' => '/admin/people/select-registration-roles-setby-admin',
)),
'#options' => $roles,
);
}
else {
$approval_roles = array_filter(variable_get('select_registration_roles_admin_approval', $roles));
$all_roles = select_registration_roles_get_all_roles();
$display_roles = array_intersect_key($all_roles, $display_roles);
foreach ($display_roles as $role_id => $role_name) {
if (in_array($role_id, $approval_roles)) {
$role_name .= t("<i>*needs administration approval</i>");
}
$roles[$role_id] = $role_name;
$form['select_roles'] = array(
'#type' => 'checkboxes',
'#title' => t('Choose a role'),
'#options' => $roles,
);
}
}
$form['#submit'][] = 'select_registration_roles_form_submit';
}