I've added token support to the referral.module. Try it out - just paste the code below into the bottom of the module, and it should work fine.

<?php
/**
 * Implementation of hook_token_values().
 */
function referral_token_values($type, $object = NULL, $options = array()) {
  if ($type == 'user') {
    $tokens = array(
      'referral-link' => url('referral/'. _referral_uid2ref($object->uid), array('query' => NULL, 'fragment' => NULL, 'absolute' => TRUE)),
    );
    return $tokens;
  }
}

/**
 * Implementation of hook_token_list().
 */
function referral_token_list($type = 'all') {
  if ($type == 'user' || $type == 'all') {
    $tokens['user'] = array(
      'referral-link' => t('The referral link for this user.'),
    );
    return $tokens;
  }
}
?>

Comments

kbahey’s picture

Status: Active » Needs review

If someone tests it and finds that it works, I will commit it.

phacts’s picture

I've just used it on a production site (with the mailchimp module, I'm sending the referral link to mailchimp via the token), and it works great. Of course, I've only been using it for 2 hours!

kbahey’s picture

OK, post again in a couple of days. If all is well, I will commit it.

phacts’s picture

It still works - I've been using it now for two weeks on the production site, and the token generates correctly every time.

kbahey’s picture

Status: Needs review » Fixed

I committed the code. The only thing I changed is I removed this part:

'query' => NULL, 'fragment' => NULL,

A tarball will be created in about 12 hours from the time of this message.

Please wait until then and test it. Post here if it does not work.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.