I am using CCK to create a content type of "Issue" that is then assigned to a user to work on using workflow, actions, triggers etc. In CCK I have created a custom field variable called 'field_assigned_to'. When the 'Issue' is assigned to a user, that user will receive an email telling them that it has been assigned to them. I am using a send tokenized email action, the problem is that there is no placeholder token for email associated with the 'field_assigned_to' variable, the available placeholders are, [field_assigned_to-uid], [field_assigned_to-name], [field_assigned_to-link],
[field_assigned_to-path] and [field_assigned_to-url], I need to have the email address associated with field_assigned_to-uid in order to populate the 'To' textbox on the form when creating the tokenized email. Any ideas on how to get it into that textbox?

Comments

dave reid’s picture

Project: Token » Content Construction Kit (CCK)
Version: 6.x-1.12 » 6.x-2.6
Component: Miscellaneous » Token Integration

Node & user reference tokens are provided by CCK.module, not token.module. I'll transfer your issue to the cck issue queue where someone better handled to answer your request can reply.

puddyglum’s picture

I had this exact same problem, modified the code of modules/cck/includes/content.token.inc:

lines I added: $tokens['user reference']['mail'] = t("E-mail address of the referenced user.");

      $user = user_load($item['uid']);
      $tokens['mail']  = isset($user->mail) ? $user->mail : '';

So the userreference_token_list() looks like this now:

if (module_exists('userreference')) {
  function userreference_token_list($type = 'all') {
    if ($type == 'field' || $type == 'all') {
      $tokens = array();

      $tokens['user reference']['uid']   = t('Referenced user ID');
      $tokens['user reference']['name']  = t('Referenced user name');
      $tokens['user reference']['link']  = t('Formatted HTML link to referenced user');
      $tokens['user reference']['path']  = t("Relative path alias to the referenced user.");
      $tokens['user reference']['url']  = t("Absolute path alias to the referenced user.");
      $tokens['user reference']['mail']  = t("E-mail address of the referenced user.");

      return $tokens;
    }
  }

  function userreference_token_values($type, $object = NULL) {
    if ($type == 'field') {
      $item = $object[0];

      $tokens['uid']   = $item['uid'];
      $tokens['name']  = isset($item['view']) ? strip_tags($item['view']) : '';
      $tokens['link']  = isset($item['view']) ? $item['view'] : '';
      $tokens['path'] = is_numeric($item['uid']) ? url('user/' . $item['uid']) : '';
      $tokens['url'] = is_numeric($item['uid']) ? url('user/' . $item['uid'], array('absolute' => TRUE)) : '';

      $user = user_load($item['uid']);
      $tokens['mail']  = isset($user->mail) ? $user->mail : '';

      return $tokens;
    }
  }
}
puddyglum’s picture

I think this should be updated, because e-mail is VERY important to have

J3’s picture

Exact same problem for me. Anyone get an update for this?

marcp’s picture

Status: Active » Closed (duplicate)