/**
  * Signups
  * @since 1.4
  * @version 1.2
  */
 public function site_signup($new_user_id)
 {
     // Requirement
     $ref = false;
     $key = '';
     if (isset($_COOKIE['signup_ref' . $this->mycred_type])) {
         $ref = $_COOKIE['signup_ref' . $this->mycred_type];
         $key = 'signup_ref' . $this->mycred_type;
     } elseif (isset($_COOKIE['mycred_ref' . $this->mycred_type])) {
         $ref = $_COOKIE['mycred_ref' . $this->mycred_type];
         $key = 'mycred_ref' . $this->mycred_type;
     }
     if ($ref === false) {
         return;
     }
     // Attempt to get the user id based on the referrer
     $user_id = $this->get_user_id_from_ref_id($ref);
     if ($user_id === false) {
         if (!headers_sent()) {
             setcookie($key, $ref, time() - 3600, '/');
         }
         return;
     }
     // Delete Cookie
     if (!headers_sent()) {
         setcookie($key, $ref, time() - 3600, '/');
     }
     // Attempt to get the users IP
     $IP = apply_filters('mycred_affiliate_IP', $_SERVER['REMOTE_ADDR'], 'signup', $this);
     if ($IP != '' && $IP != '0.0.0.0') {
         if ($this->ref_counts($user_id, $IP, 'signup')) {
             // Award when users account gets activated
             if (function_exists('buddypress') && apply_filters('bp_core_signup_send_activation_key', true) === true) {
                 mycred_add_user_meta($new_user_id, 'referred_by', '', $user_id);
                 mycred_add_user_meta($new_user_id, 'referred_by_IP', '', $IP);
                 mycred_add_user_meta($new_user_id, 'referred_by_type', '', $this->mycred_type);
             } else {
                 $this->core->add_creds('signup_referral', $user_id, $this->prefs['signup']['creds'], $this->prefs['signup']['log'], $new_user_id, $IP, $this->mycred_type);
                 do_action('mycred_signup_referral', $user_id, $IP, $new_user_id, $this);
             }
         }
     }
 }
 /**
  * Email Notice Check
  * @since 1.1
  * @version 1.4
  */
 public function email_check($reply, $request, $mycred)
 {
     // Exit now if reply is false or new settings is not yet saved.
     if ($reply === false || !isset($this->emailnotices['send'])) {
         return $reply;
     }
     $user_id = absint($request['user_id']);
     // Construct events
     $events = $this->get_events_from_instance($request, $mycred);
     // Do not send emails now
     if ($this->emailnotices['send'] != '') {
         // Save for cron job
         mycred_add_user_meta($user_id, 'mycred_scheduled_email_notices', '', array('events' => $events, 'request' => $request));
     } else {
         $this->do_email_notices($events, $request);
     }
     return $reply;
 }
 /**
  * Email Notice Check
  * @since 1.1
  * @version 1.5
  */
 public function email_check($ran, $request, $mycred)
 {
     // Exit now if $ran is false or new settings is not yet saved.
     if ($ran === false || !isset($this->emailnotices['send'])) {
         return $ran;
     }
     $user_id = absint($request['user_id']);
     // Construct events
     $events = $this->get_events_from_instance($request, $mycred);
     // Badge Related
     if (function_exists('mycred_ref_has_badge')) {
         /*
         	In order for us to save on database queries down the line, we will
         	check if the user got any badges for this instnace and save the badge ids
         	under "badges".
         	
         	Since the process is already completed and we are simply "reacting" to the
         	event, we can manipulte $request without it having any effect on other features.
         */
         $badge_ids = mycred_ref_has_badge($request['ref']);
         if (!empty($badge_ids)) {
             $badges = mycred_check_if_user_gets_badge($user_id, $badge_ids, false);
             if (!empty($badges)) {
                 $events[] = 'badges|positive';
                 $request['badges'] = $badges;
             }
         }
     }
     // Do not send emails now
     if ($this->emailnotices['send'] != '') {
         // Save for cron job
         mycred_add_user_meta($user_id, 'mycred_scheduled_email_notices', '', array('events' => $events, 'request' => $request));
     } else {
         $this->do_email_notices($events, $request);
     }
     return $ran;
 }
Beispiel #4
0
 /**
  * Signups
  * @since 1.4
  * @version 1.0
  */
 public function site_signup($new_user_id)
 {
     // Requirement
     if (!isset($_COOKIE['signup_ref'])) {
         return;
     }
     // Attempt to get the user id based on the set cookie
     $user_id = $this->get_user_id_from_ref_id($_COOKIE['signup_ref']);
     if ($user_id === false) {
         setcookie('signup_ref', $_COOKIE['signup_ref'], time() - 3600);
         return;
     }
     // Delete Cookie
     setcookie('signup_ref', $_COOKIE['signup_ref'], time() - 3600);
     // If points are awarded for visitor referrals
     if ($this->ref_counts($user_id, $IP, 'signup')) {
         // Award when users account gets activated
         if (function_exists('buddypress') && apply_filters('bp_core_signup_send_activation_key', true)) {
             mycred_add_user_meta($new_user_id, 'referred_by', '', $user_id);
             mycred_add_user_meta($new_user_id, 'referred_by_IP', '', $IP);
         } else {
             $this->core->add_creds('signup_referral', $user_id, $this->prefs['signup']['creds'], $this->prefs['signup']['log'], $new_user_id, $IP, $this->mycred_type);
         }
     }
     // Let others play
     do_action('mycred_affiliate_signup', $new_user_id, $user_id, $this);
 }