For some reason when creating an advanced action that sends an email, only the global variables return anything other than passing the variables through. For instance:

If you have an action set up that sends an email with using variables only %username %site_name will return information, the following variables email straight through in plain text.
%username, %node_url, %node_type, %title, %teaser, %body

It is worth noting that %username and %site_name are global while the other appear to be "checked plain in the following code." Could something be getting stripped out?

Some of the relating code begins on line 1662 of the system module.

/**
 * A configurable Drupal action. Sends a message to the current user's screen.
 */
function system_message_action(&$object, $context = array()) {
  global $user;
  $variables = array(
    '%site_name' => variable_get('site_name', 'Drupal'),
    '%username' => $user->name ? $user->name : variable_get('anonymous', t('Anonymous')),
  );

  // This action can be called in any context, but if placeholders
  // are used a node object must be present to be the source
  // of substituted text.
  switch ($context['hook']) {
    case 'nodeapi':
      // Because this is not an action of type 'node' the node
      // will not be passed as $object, but it will still be available
      // in $context.
      $node = $context['node'];
      break;
    // The comment hook also provides the node, in context.
    case 'comment':
      $comment = $context['comment'];
      $node = node_load($comment->nid);
      break;
    case 'taxonomy':
      $vocabulary = taxonomy_vocabulary_load($object->vid);
      $variables = array_merge($variables, array(
        '%term_name' => $object->name,
        '%term_description' => $object->description,
        '%term_id' => $object->tid,
        '%vocabulary_name' => $vocabulary->name,
        '%vocabulary_description' => $vocabulary->description,
        '%vocabulary_id' => $vocabulary->vid,
        )
      );
      break;
    default:
      // We are being called directly.
      $node = $object;
  }

  if (isset($node) && is_object($node)) {
    $variables = array_merge($variables, array(
      '%uid' => $node->uid,
      '%node_url' => url('node/'. $node->nid, array('absolute' => TRUE)),
      '%node_type' => check_plain(node_get_types('name', $node)),
      '%title' => filter_xss($node->title),
      '%teaser' => filter_xss($node->teaser),
      '%body' => filter_xss($node->body),
      )
    );
  }
  $context['message'] = strtr($context['message'], $variables);
  drupal_set_message($context['message']);
}

Forgive me if I have misreported. I was following along in reading the fabulous "Using Drupal" and could not get the directions to work in two different Drupal 6 installations.

Other people have had this problem:
http://forums.oreilly.com/content/Using-Drupal/3827/Chapter-6-Action-Var...

The only other posts related to Drupal 7 and it was unclear if it was noted as well for Drupal 6. - Thanks

Comments

mikeybusiness’s picture

I'm guessing that there could be any number of things happening.

1. The variables do not have a chance to get returned, because of when they are executed.
2. For security reasons the variables are stripped out and passed through as plain text.
3. Syntax - somewhere

multiplextor’s picture

Status: Active » Closed (won't fix)

Closed. The reason: expired.

sherab’s picture

Version: 6.12 » 6.18
StatusFileSize
new603 bytes

The problem is still present in version 6.18 of Drupal.

One thing that seems to work, at least when the action is linked with the node submission trigger,is the included patch.

Not sure it doesn't break something else, though.