diff -cr linkedin/linkedin_auth/linkedin_auth.module linkedin.patched/linkedin_auth/linkedin_auth.module
*** linkedin/linkedin_auth/linkedin_auth.module	Mon Jan  2 14:58:38 2012
--- linkedin.patched/linkedin_auth/linkedin_auth.module	Wed Mar 21 18:48:43 2012
***************
*** 34,41 ****
    //register new user if no account linked
    $items['linkedin/register/create'] = array(
      'page callback' => 'drupal_get_form',
!     'page arguments' => array('linkedin_auth_register_page'),
!     'access callback' => 'user_is_anonymous',
      'type' => MENU_CALLBACK,
      'file' => 'linkedin_auth.pages.inc',
    );
--- 34,41 ----
    //register new user if no account linked
    $items['linkedin/register/create'] = array(
      'page callback' => 'drupal_get_form',
!     'page arguments' => array('user_register'), //array('linkedin_auth_register_page'),
!     'access callback' => 'user_register_access',
      'type' => MENU_CALLBACK,
      'file' => 'linkedin_auth.pages.inc',
    );
***************
*** 83,91 ****
          '#value' => theme('linkedin_auth_display_login_block_button', 'drupal_login_page'),
          '#weight' => 1,
        );
!     }
      return $form;
    }
  }
  
  /**
--- 83,107 ----
          '#value' => theme('linkedin_auth_display_login_block_button', 'drupal_login_page'),
          '#weight' => 1,
        );
!     } 
      return $form;
    }
+   elseif ($form_id == 'user_register' && ($_SESSION['linkedin_not_linked'] == 1)) {
+     $form['#redirect'] = isset($_REQUEST['destination']) ? $_REQUEST['destination'] : '';
+     
+     // Ensure a valid submit array.
+     $form['#submit'] = is_array($form['#submit']) ? $form['#submit'] : array();
+ 
+     // Replace core's registration function with LT's registration function.
+     // Put the LT submit handler first, so other submit handlers have a valid
+     // user to work with upon registration.
+     $key = array_search('user_register_submit', $form['#submit']);
+     if ($key !== FALSE) {
+       unset($form['#submit'][$key]);
+     }
+     $form['#submit'] = array_merge(array('linkedin_auth_register_form_submit'), $form['#submit']);
+     return $form;
+   } 
  }
  
  /**
diff -cr linkedin/linkedin_auth/linkedin_auth.pages.inc linkedin.patched/linkedin_auth/linkedin_auth.pages.inc
*** linkedin/linkedin_auth/linkedin_auth.pages.inc	Mon Jan  2 14:58:38 2012
--- linkedin.patched/linkedin_auth/linkedin_auth.pages.inc	Wed Mar 21 18:49:56 2012
***************
*** 42,75 ****
  }
  
  /**
!  * Menu callback.
!  * Called when user perform linkedin registration
!  */
! function linkedin_auth_register_page($form_state = array()) {
! 
!   $user_reg_mode = variable_get('user_register', 1);
!   if ($user_reg_mode == 0) {
!     drupal_access_denied();
!     return;
!   }
!   $form = drupal_retrieve_form('user_register', $form_state);
!   drupal_prepare_form('user_register', $form, $form_state);
!   $form['name']['#default_value'] = $data['name'];
!   $form['#redirect'] = isset($_REQUEST['destination']) ? $_REQUEST['destination'] : '';
! //  Only remove standard register submit, but play nicely wth other modules.
!   $key = array_keys($form['#submit'], 'user_register_submit');
!   unset($form['#submit'][$key[0]]);
!   $form['#submit'][] = 'linkedin_auth_register_form_submit';
!   return $form;
! }
! 
  function linkedin_auth_register_form_submit($form, &$form_state) {
-   user_external_login_register($form_state['values']['name'], 'linkedin');
    global $user;
    $account = user_save($user, $form_state['values']);
    if (!$account) {
      drupal_set_message(t("Error saving user account."), 'error');
      drupal_goto();
!   }  
    linkedin_access_token($account);  
! }
\ No newline at end of file
--- 42,67 ----
  }
  
  /**
!   * Form Submit hook
!   *
!   * See http://api.drupal.org/api/drupal/modules!user!user.module/function/user_external_login_register/6 for added code
!   */
  function linkedin_auth_register_form_submit($form, &$form_state) {
    global $user;
+   $anonymous_user = $user; // Store anon
+ 
+   // Setup variables for registration
+   user_external_login_register($form_state['values']['name'], 'linkedin');
    $account = user_save($user, $form_state['values']);
+   $registered_user = $user;
+ 
+   // Reset the $user object. user_external_login() behaves strangely and if we don't do this
+   // all users $user->uid is set to 0 :/.
+   $user = $anonymous_user;
    if (!$account) {
      drupal_set_message(t("Error saving user account."), 'error');
      drupal_goto();
!   }
!   user_external_login($registered_user);
    linkedin_access_token($account);  
! }
