Index: user_types.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/user_types/user_types.module,v
retrieving revision 1.1.2.7
diff -u -r1.1.2.7 user_types.module
--- user_types.module	12 Dec 2007 01:23:24 -0000	1.1.2.7
+++ user_types.module	12 Dec 2007 14:56:21 -0000
@@ -33,7 +33,16 @@
       'type' => MENU_LOCAL_TASK,
       'weight' => 1,
     );
-
+    $items[] = array(
+      'path' => 'choosetype',
+      'title' => t('chose a type'),
+      'access' => user_access('access content'),
+      'callback' => 'drupal_get_form',
+      'callback arguments' => array('user_types_set_type'),
+      'type' => MENU_CALLBACK,
+      'weight' => 1,
+    );
+    
     foreach (user_types_list() as $user_type_id => $name) {
       $items[] = array(
         'path' => 'admin/user/user_types/'. check_plain($name),
@@ -233,9 +242,64 @@
     case 'insert':
       db_query('INSERT INTO {user_types_user} (uid, user_type_id) VALUES (%d, %d)', $account->uid, user_types_add_page_id());
       break;
+    case 'login':
+      $hastype = db_result(db_query("SELECT uid FROM {user_types_user} WHERE uid = '%d'", $account->uid));
+      if(!$hastype){
+        unset($_REQUEST['destination']);
+        drupal_goto('choosetype');
+        
+      }
+      break;
   }
 }
 
+function user_types_set_type() {
+  $form = array();
+  
+  $result = db_query("SELECT name FROM {user_types_type}");
+  $types[] = variable_get('user_types_set_type', t('normal user'));
+  $i=0;
+  drupal_set_message($user->uid);
+  
+  while($type = db_result($result,$i)){
+    $types[] = $type;
+    $i++;
+  }
+  
+  $form['user_types_set_type'] = array(
+    '#title' => t('user type settings'),
+    '#type' => 'fieldset',
+    '#collapsible' => TRUE,
+    '#collapsed' => FALSE
+  );
+  $form['user_types_set_type_options'] = array(
+    '#type' => 'value',
+    '#value' => $types
+  );
+  $form['user_types_set_type']['type'] = array(
+    '#title' => t('select your type'),
+    '#type' => 'select',
+    '#description' => t('select your type'),
+    '#options' => $form['user_types_set_type_options']['#value']
+  );
+  
+  $form['submit'] = array(
+    '#type' => 'submit',
+    '#value' => t('Save settings'),
+  );
+
+  return $form;
+}
+
+function user_types_set_type_submit($form_id, $form_values) {
+  global $user;
+  $key = $form_values['type'];
+  $type = db_result(db_query("SELECT user_type_id FROM {user_types_type} WHERE name = '%s'", $form_values['user_types_set_type_options'][$key])); 
+  db_query('INSERT INTO {user_types_user} (uid, user_type_id) VALUES (%d, %d)', $user->uid, $type);
+  drupal_set_message('Saved your type.');
+  return 'node';
+}
+
 function user_types_profile_field_form_submit($form_id, $form_values) {
   if (isset($form_values['fid'])) {
     $fid = $form_values['fid'];

