Index: registration_role.module =================================================================== --- registration_role.module (revision 2603) +++ registration_role.module (working copy) @@ -58,6 +58,12 @@ '#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.'), ); + $form['registration_role_ignore_admin_create'] = array( + '#type' => 'checkbox', + '#title' => t('Ignore role for admin created users'), + '#default_value' => variable_get('registration_role_ignore_admin_create', FALSE), + '#description' => t('Disable adding this role to users created using the admin form at !adminadd', array('!adminadd' => l('admin/user/user/create', 'admin/user/user/create'))), + ); // $form['array_filter'] = array('#type' => 'hidden'); // Drupal 5, mysterious, needed for multiple check box values using settings hook return system_settings_form($form); @@ -68,11 +74,12 @@ * * Catch every registration and insert role */ - -function registration_role_user ($op, &$edit, &$user, $category=null) -{ - if ($op == "insert" && $rid = variable_get('registration_role_roles', '')) - { +function registration_role_user ($op, &$edit, &$user, $category=null) { + $access = user_access('administer users'); + $ignore = variable_get('registration_role_ignore_admin_create', FALSE); + $rid = variable_get('registration_role_roles', ''); + + if ($op == 'insert' && $rid && (!$access || ($access && !$ignore))) { // below does not seem safe! or necessary for insert. Commented out // clear first // db_query( 'DELETE FROM {users_roles} WHERE uid = %d', $user->uid );