Ooops ... I included a function from the notify module that I used for the hook_user reference that shouldn't be in there ... create autoassignrole.module with this code and not the previous ... Sorry about that
<?php define("AUTOASSIGNROLE_ROLE", ""); /** * Implementation of hook_menu(). * * @return array */ function autoassignrole_menu($may_cache) { $items = array(); if ($may_cache) { $items[] = array( 'path' => 'admin/settings/autoassignrole', 'title' => t('Auto Assign Role Settings'), 'description' => t('Auto Assign Role Settings page.'), 'callback' => 'drupal_get_form', 'callback arguments' => 'autoassignrole_settings', 'access' => user_access('administer autoassignrole'), ); } return $items; } function autoassignrole_settings() { $form['autoassignrole_settings'] = array( '#type' => 'fieldset', '#title' => t('Auto Assign Role Settings'), '#collapsible' => FALSE, '#collapsed' => FALSE, ); $form['autoassignrole_settings']['AUTOASSIGNROLE_ROLE'] = array( '#type' => 'textfield', '#title' => t('.'), '#default_value' => variable_get('AUTOASSIGNROLE_ROLE', ''), '#size' => 70, '#maxlength' => 255, '#description' => t('The role you want new users assigned to.') ); return system_settings_form($form); } /** * Implementation of hook_perm(). * @return array */ function autoassignrole_perm() { return array('administer autoassignrole'); }
/** * Implementation of hook_user(). */ function autoassignrole_user($type, &$edit, &$user, $category = NULL) { switch ($type) { case 'insert': $sql = "SELECT r.rid FROM {role} r WHERE r.name = '%s'"; $role = db_fetch_object(db_query($sql,variable_get('AUTOASSIGNROLE_ROLE',''))); db_query('INSERT INTO {users_roles} (uid, rid) values (%d, %d)', $user->uid, $role->rid ); break; } }