/**
  * Record a referral when a new user has been referred by an affiliate.
  * 
  * @param int $user_id
  * @param array $params registration parameters
  */
 public static function user_register($user_id, $params = array())
 {
     extract($params);
     if (!isset($force)) {
         $force = false;
     }
     if (!isset($type)) {
         $type = null;
     }
     if (!$force && is_admin()) {
         if (!apply_filters('affiliates_user_registration_on_admin', false)) {
             return;
         }
     }
     if ($user = get_user_by('id', $user_id)) {
         $post_id = null;
         if ($post = get_post()) {
             $post_id = $post->ID;
         }
         switch ($type) {
             case 'customer':
                 $description = sprintf('Customer Registration %s', esc_html($user->user_login));
                 break;
             default:
                 $description = sprintf('User Registration %s', esc_html($user->user_login));
         }
         $base_amount = null;
         if (AFFILIATES_PLUGIN_NAME != 'affiliates') {
             $base_amount = get_option('aff_user_registration_base_amount', null);
         }
         $amount = null;
         if (empty($base_amount)) {
             $amount = get_option('aff_user_registration_amount', '0');
         }
         $currency = get_option('aff_user_registration_currency', Affiliates::DEFAULT_CURRENCY);
         $user_registration_referral_status = get_option('aff_user_registration_referral_status', get_option('aff_default_referral_status', AFFILIATES_REFERRAL_STATUS_ACCEPTED));
         $data = array('user_login' => array('title' => 'Username', 'domain' => AFFILIATES_PLUGIN_DOMAIN, 'value' => $user->user_login), 'user_email' => array('title' => 'Email', 'domain' => AFFILIATES_PLUGIN_DOMAIN, 'value' => $user->user_email), 'first_name' => array('title' => 'First Name', 'domain' => AFFILIATES_PLUGIN_DOMAIN, 'value' => $user->first_name), 'last_name' => array('title' => 'Last Name', 'domain' => AFFILIATES_PLUGIN_DOMAIN, 'value' => $user->last_name), 'base_amount' => array('title' => 'Base Amount', 'domain' => AFFILIATES_PLUGIN_DOMAIN, 'value' => $base_amount));
         if (class_exists('Affiliates_Referral_WordPress')) {
             $r = new Affiliates_Referral_WordPress();
             $affiliate_id = $r->evaluate($post_id, $description, $data, $base_amount, $amount, $currency, $user_registration_referral_status, self::REFERRAL_TYPE);
         } else {
             $affiliate_id = affiliates_suggest_referral($post_id, $description, $data, $amount, $currency, $user_registration_referral_status, self::REFERRAL_TYPE);
         }
     }
 }