Index: inline_registration.module
===================================================================
--- inline_registration.module	(revision 2)
+++ inline_registration.module	(working copy)
@@ -1,17 +1,14 @@
 <?php
-
 /**
  * Implementation of hook_form_alter().
  */
 function inline_registration_form_alter(&$form, $form_state, $form_id) {
-  //
 
   if ($form['#id'] == 'node-form' && arg(1) == 'add') { // This is a node/add form
-  //
-
+    $types = variable_get('inline_registration_content_types', array());
     global $user;
 
-    if ($user->uid == 0) { // User is not logged in
+    if ($user->uid == 0 && in_array($form['type']['#value'], $types)) { // User is not logged in and type is one we want to register on
 
       // Add the user registration form to the node/add/page
       $form['register'] = array(
@@ -22,8 +19,8 @@
         '#collapsed' => FALSE,
         '#weight' => -99,
       );
-      $form['register']['form'] = user_register();
-
+      $form['register']['form'] = drupal_retrieve_form('user_register', $form_state);
+      
       // Remove the user_register submit button in favor of the node submit button
       unset($form['register']['form']['submit']);
 
@@ -31,12 +28,12 @@
       $form['register']['form']['name']['#title'] = t('Choose a Username');
 
       // Add our own validation and submit function to the node_form
-      $form['#validate']['inline_registration_validate'] = array();
-      $form['#submit']['inline_registration_submit'] = array();
+      $form['#validate'][] = 'inline_registration_validate';
+      $form['#submit'][] = 'inline_registration_submit';
 
       // And ensure our submit function is called first (so the node is authored by the newly created user)
       $form['#submit'] = array_reverse($form['#submit']);
-      print_r($form);
+
     }
   }
 }
@@ -46,14 +43,14 @@
  */
 function inline_registration_validate($form, &$form_state) {
   // Validate using user module's validation routine
-  $account = $form_state['values']['_account'];
-  
-  user_module_invoke('validate', $form_state['values'], $form_state['values'], 'account');
+  $account = $form_state['values'];
 
   // Why doesn't user_module_invoke('validate') check if the username is taken? We'll do that now.
   if (db_fetch_object(db_query("SELECT uid FROM {users} WHERE name = '%s'", $form_state['values']['name']))) {
     form_set_error('name', t('The name %name is already taken.', array('%name' => $form_state['values']['name'])));
   }
+  
+  user_module_invoke('validate', $form_state['values'], $form_state['values'], 'account');
 }
 
 /**
@@ -70,7 +67,7 @@
   $name = $form_state['values']['name'];
 
   if (!variable_get('user_email_verification', TRUE)) {
-    $pass = $form_values['pass'];
+    $pass = $form_state['values']['pass'];
   }
   else {
     $pass = user_password();
@@ -78,23 +75,23 @@
   $notify = FALSE;
 
   $from = variable_get('site_mail', ini_get('sendmail_from'));
-  if (isset($form_values['roles'])) {
-    $roles = array_filter($form_values['roles']);     // Remove unset roles
+  if (isset($form_state['values']['roles'])) {
+    $roles = array_filter($form_state['values']['roles']);     // Remove unset roles
   }
 
   //the unset below is needed to prevent these form values from being saved as user data
-  unset($form_values['form_token'], $form_values['submit'], $form_values['op'], $form_values['notify'], $form_values['form_id'], $form_values['affiliates'], $form_values['destination']);
+  unset($form_state['values']['form_token'], $form_state['values']['submit'], $form_state['values']['op'], $form_state['values']['notify'], $form_state['values']['form_id'], $form_state['values']['affiliates'], $form_state['values']['destination']);
 
   $merge_data = array('pass' => $pass, 'init' => $mail, 'roles' => $roles);
 
-  $account = user_save('', array_merge($form_values, $merge_data));
-  watchdog('user', t('New user: %name %email.', array('%name' => $name, '%email' => '<'. $mail .'>')), WATCHDOG_NOTICE, l(t('edit'), 'user/'. $account->uid .'/edit'));
+  $account = user_save('', array_merge($form_state['values'], $merge_data));
+  watchdog('user', t('New user: %name %email.', array('%name' => $name, '%email' => '<'. $mail .'>')), array(), WATCHDOG_NOTICE, l(t('edit'), 'user/'. $account->uid .'/edit'));
 
   // Set the node uid and name to the newly created user so node will be properly attributed to the new user when saved
-  $form_values['name'] = $account->name;
-  $form_values['uid'] = $account->uid;
+  $form_state['values']['name'] = $account->name;
+  $form_state['values']['uid'] = $account->uid;
 
-  $variables = array('!username' => $name, '!site' => variable_get('site_name', 'Drupal'), '!password' => $pass, '!uri' => $base_url, '!uri_brief' => substr($base_url, strlen('http://')), '!mailto' => $mail, '!date' => format_date(time()), '!login_uri' => url('user', NULL, NULL, TRUE), '!edit_uri' => url('user/'. $account->uid .'/edit', NULL, NULL, TRUE), '!login_url' => user_pass_reset_url($account));
+  $variables = array('!username' => $name, '!site' => variable_get('site_name', 'Drupal'), '!password' => $pass, '!uri' => $base_url, '!uri_brief' => substr($base_url, strlen('http://')), '!mailto' => $mail, '!date' => format_date(time()), '!login_uri' => url('user', array('absolute' => TRUE)), '!edit_uri' => url('user/'. $account->uid .'/edit', array('absolute' => TRUE)), '!login_url' => user_pass_reset_url($account));
 
   if (!variable_get('user_email_verification', TRUE) && $account->status) {
     // No e-mail verification is required, create new user account, and login user immediately.
@@ -131,4 +128,17 @@
     drupal_set_message(t('Thank you for applying for an account. Your account is currently pending approval by the site administrator.<br />In the meantime, your password and further instructions have been sent to your e-mail address.'));
     return '';
   }
+}
+
+function inline_registration_menu() {
+  $items['admin/settings/inline_registration'] = array(
+    'title' => t('Inline registration'),
+    'description' => t('Select the content types which should have an inline registration form.'),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('inline_registration_admin_settings'),
+    'access arguments' => array('access administration pages'),
+    'file' => 'inline_registration.pages.inc',
+  );
+  
+  return $items;
 }
\ No newline at end of file
Index: inline_registration.pages.inc
===================================================================
--- inline_registration.pages.inc	(revision 0)
+++ inline_registration.pages.inc	(revision 0)
@@ -0,0 +1,52 @@
+<?php
+function inline_registration_admin_settings() {
+
+  $content_types = node_get_types();
+  foreach($content_types as $type){
+    $types[$type->type] = $type->type;
+  }
+  
+  $form['content_types'] = array(
+    '#title' => 'Content types to retrieve',
+    '#type' => 'checkboxes',
+    '#options' => $types,
+    '#default_value' => variable_get('inline_registration_content_types', array()),
+  );	  
+  $form['submit'] = array(
+    '#value' => 'Save settings',
+    '#type' => 'submit',
+  );
+  
+  return $form;
+}
+
+
+/**
+ * submit function for the 'Content Types' form sets variables for this module:
+ * 
+ * inline_registration_content_types 
+ * an array of content types to be retrieved
+ * 
+ */
+function inline_registration_admin_settings_submit($form, &$form_state) {
+  //organise the content types in to the correct format
+  $selected_types = array();
+  $selected_types = $form_state['values']['content_types'];
+  $save_types = array();
+  $count = 0;
+  foreach ($selected_types as $selected_type) {
+    if ($selected_type != '0') {
+      $count++;
+      $save_types[] = $selected_type;
+    }
+  }
+  //inform user if the module is disabled by their content choices
+  if ($count == 0) {
+    drupal_set_message(t('No content types were selected. Module disabled.'), 'error');
+  }
+  
+  //save the variables
+  variable_set('inline_registration_content_types', $save_types);
+  
+  drupal_set_message(t('Settings saved.'));
+}
\ No newline at end of file
