You are here

function rules_action_fetch_referring_user in User Referral 7

Rules action callback

1 string reference to 'rules_action_fetch_referring_user'
referral_rules_action_info in ./referral.rules.inc
Implements hook_rules_action_info().

File

./referral.rules.inc, line 249
Rules integration

Code

function rules_action_fetch_referring_user($user) {
  $query = db_select('referral', 'r')
    ->fields('r', array(
    'referral_uid',
  ))
    ->condition('uid', $user->uid)
    ->execute()
    ->fetchAll();
  $referral_uid = isset($query[0]->referral_uid) ? $query[0]->referral_uid : NULL;
  $referrer = $referral_uid ? user_load($referral_uid) : NULL;
  return array(
    'referring_user' => $referrer,
  );
}