--- sites/all/modules/referral/referral.module	Wed Jan 02 13:55:00 2008
+++ sites/all/modules/referral/referral.module	Fri Feb 08 12:58:18 2008
@@ -198,11 +198,25 @@
     $cookie['referer']);
 
   if (db_affected_rows()) {
     if (module_exists('userpoints')) {
       $points = variable_get(REFERRAL_USERPOINTS, 1);
-      userpoints_userpointsapi('points', $points, $cookie[$uid], 'referral');
+      // Build the userpoints params array
+      $params = array(
+        'points' => $points,
+        'uid' => $cookie[$uid],
+        'operation' => 'referral',
+        'entity_id' => $cookie[$uid],
+        'entity_type' => 'user',
+        'reference' => 'referral'
+      );
+      
+      // Award the points to the user
+      userpoints_userpointsapi($params);
+      
+      // Check to see if the role needs to be elevated
+      userpoints_role_userpoints('points after', 0, $cookie[$uid], '');
     }
   }
   else {
     watchdog('referral', t('INSERT of referral data failed.'), WATCHDOG_ERROR);
   }
