*** sites/all/modules/bio/bio.module.orig	2009-11-18 11:23:02.000000000 -0500
--- sites/all/modules/bio/bio.module	2009-11-18 11:27:45.000000000 -0500
***************
*** 168,201 ****
   * on registration if any bio fields are set to show on the registration form.
   */
  function bio_user_register_submit($form_values) {
!   // Create bio node for this user.
!   $node = new StdClass;
!   $node->type = bio_get_type();
!   $node->uid = db_result(db_query("SELECT uid FROM {users} WHERE name = '%s'", $form_values['name']));
!   $node->title = $form_values['name'];
!   $node->name = $form_values['name'];
!   node_object_prepare($node);
! 
!   $node_options = variable_get('node_options_'. $node->type, array('status', 'promote'));
!   foreach (array('status', 'promote', 'sticky') as $key) {
!     $node->$key = in_array($key, $node_options);
!   }
!   // Always use the default revision setting.
!   $node->revision = in_array('revision', $node_options);
    
!   foreach ($form_values as $field_name => $value) {
!     if (preg_match('/^field_/', $field_name)) {
!       $node->$field_name = $form_values[$field_name];
      }
-   }
- 
-   // Create the node.
-   $node = node_submit($node);
-   node_save($node);
- 
-   // Give us a nice log message.
-   if ($node->nid) {
-     watchdog('content', t('Bio: added %user bio upon registration.', array('%user' => $node->name)), WATCHDOG_NOTICE, l(t('view'), "node/$node->nid"));
    }
  }
  
--- 168,205 ----
   * on registration if any bio fields are set to show on the registration form.
   */
  function bio_user_register_submit($form_values) {
!   $new_user_uid = db_result(db_query("SELECT uid FROM {users} WHERE name = '%s'", $form_values['name']));
!       // see http://drupal.org/node/310877; only go through this if the bio does not already exist. The bio might already exist if someone has repeatedly registered with the same username, using the browser's back button and resaving repeatedly.
!   if(!bio_for_user($new_user_uid)) { 
!     // Create bio node for this user.
!     $node = new StdClass;
!     $node->type = bio_get_type();
!     $node->uid = $new_user_uid;
!     $node->title = $form_values['name'];
!     $node->name = $form_values['name'];
!     node_object_prepare($node);
    
!     $node_options = variable_get('node_options_'. $node->type, array('status', 'promote'));
!     foreach (array('status', 'promote', 'sticky') as $key) {
!       $node->$key = in_array($key, $node_options);
!     }
!     // Always use the default revision setting.
!     $node->revision = in_array('revision', $node_options);
!     
!     foreach ($form_values as $field_name => $value) {
!       if (preg_match('/^field_/', $field_name)) {
!         $node->$field_name = $form_values[$field_name];
!       }
!     }
!   
!     // Create the node.
!     $node = node_submit($node);
!     node_save($node);
!   
!     // Give us a nice log message.
!     if ($node->nid) {
!       watchdog('content', t('Bio: added %user bio upon registration.', array('%user' => $node->name)), WATCHDOG_NOTICE, l(t('view'), "node/$node->nid"));
      }
    }
  }
  
***************
*** 342,349 ****
      global $user;
      $uid = $user->uid;
    }
! 
!   return db_result(db_query('SELECT nid FROM {bio} WHERE uid = %d', $uid));
  }
  
  /**
--- 346,359 ----
      global $user;
      $uid = $user->uid;
    }
!   
!   $result = db_query('SELECT nid FROM {bio} WHERE uid = %d', $uid);
!   
!   if(db_num_rows($result) > 1) {
!     watchdog('bio', t('There is more than one bio node for the user ' . $uid), WATCHDOG_ERROR);
!   }
!   
!   return db_result($result);
  }
  
  /**
