I'm new to tokens, but they look awesome. I'm trying to send a tokenized email as an action after content is updated. It sends the email, but all of my tokens appear without being rendered. For instance the email I receive is:

The following work order has been requested via the website:
[field_wor_id_maintenance-raw] requested by [author-name] [body] View this
online here: [url]

I have three problems, one is obviously the tokens, the second is my line breaks are missing. Third is I can't find a token listed for the body of the node, is [body] one or is there no way to include the body? Help! What am I doing wrong?



cindyr’s picture

Title: sending an actino - tokens appear as [token] » action sending email - tokens appear as [token]

correcting the title

ifoundthetao’s picture

I too am having this problem.

I'm using Views, CCK rc-9, Tokens, Trigger is enabled, and Rules too.

Drupal version 6.4

robertDouglass’s picture

Priority: Normal » Critical

Confirmed the problem when creating a tokenized redirect action. [uid] renders as [uid], not as the user id. Marking as critical since this is the module's core functionality.

greggles’s picture

Category: support » bug

@robertDouglass - thanks for confirming the bug. In terms of maintenance on this module, Eaton wrote it. I don't use it and barely understand it. So, if you want a fix you're probably going to have to provide something that I can review.

ifoundthetao’s picture

I really know NOTHING about programming modules in Drupal, however, I do know PHP and MySQL, so from my investigating I have come up with several things..

line 20

function node_token_values($type, $object = NULL, $options = array()) {
  $values = array();
  switch ($type) {
    case 'node':
      $node = $object;
      $account_mail = db_result(db_query("SELECT mail FROM {users} WHERE uid = %d", $node->uid));

$type = "recipient"
$object = recipient's email address

So, I think we can add another case in here for 'recipient' and do the db_queries to get the info we need.

I could be wrong though. Let me know if that's OK or if it is flawed.

greggles’s picture

@ifoundthetao - the uid token comes from token_user.inc.

ifoundthetao’s picture

Actually, I copied those lines of code directly from token_node.inc ..

I got it working for me..
But this is what I did..

case 'recipient':
        global $user;

		$node = db_fetch_array(db_query("SELECT title, {node}.nid, status, field_ticket_category_value AS category, field_ticket_priority_value AS priority, field_ticket_description_value AS description FROM {node}, {content_type_ticket} WHERE uid=11 AND type='ticket' AND {node}.nid={content_type_ticket}.nid GROUP BY {node}.nid ORDER BY MAX({node}.changed) DESC LIMIT 1"));
		$values['ticket-nid'] = $node['nid'];
		$values['ticket-title'] = $node['title'];
		switch($node['priority']) {
			case 1:
			case 3:
			case 5:
		$values['ticket-priority'] = $node['priority'];
		$values['ticket-status'] = $node['status'];
		$values['ticket-category'] = $node['category'];
		$values['ticket-description'] = $node['description'];

OK, so, if you don't know how to program in PHP or with MySQL, this might be a bit confusing...
But I just set up another "case" which I put in after the original case for "node" ended..

then I got the user variables, checked for the users latest updated node.

It does this by checking the node table, and then it gets the NID and then I go to the table that I need my data from, in this case content_type_ticket, and gets the data from the rows.

So if you want to update it to work for you specifically..

Just change the table that you want to get your data from, edit the fields to be what data you want, and then make your own token.

It might not be pretty, but it works for me.

idflorin’s picture

could someone wright a patch ?

nickgs’s picture

Is there a token for the body of the node?? I don't seem to see it either?



greggles’s picture

There is no token for the node body. Token (in it's current incarnation) has to very carefully balance the desire for tokens with the speed of generating the token. Maybe that will change with a token "2.x" whenever it is released.

nickgs’s picture

Interesting. I have found a simple solution here:




Dave Reid’s picture

Component: Documentation » Token Actions
Dave Reid’s picture

Version: 6.x-1.11 » 6.x-1.x-dev
Priority: Critical » Normal
Status: Active » Postponed (maintainer needs more info)

This will need to be re-confirmed with the latest 6.x-1.x code since #635570: Most tokens do not work in tokenized E-mails: [account:user], [account:mail] was fixed.

Dave Reid’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

Closed due to lack of feedback.