views:

24

answers:

1

Hi,

I'm having some problems setting up a tokenized email to use the tokens I've created in my module. I am using this in a tokenized email [example-contact]. I've implemented the example_token_values() and example_token_list() in my module and I've also created a trigger in my module. My module has a form, created with the form API, that gets stored in a custom table. My tokens are listed when I view all available token so I know that example_token_list() is working but when example_token_values() is called $type doesn't come up as equal to 'example'.

I need to pull information from the submitted form and display them on the tokenized email that is sent out. Am I missing a function? The Trigger I created is working and fires when the form is submitted and the Action is sending out the email the problem is that the tokens are not being replace with the form's values.

Is there a function that I need to implement that will call example_token_values("example",$form)?

+1  A: 

An implementation of hook_token_values() can use any values for $object; if the module needs to use the value of $form passed to one of its functions, it can use it.

kiamlaluno
How do I retrieve the values from the form when in the hook_token_values()? Also according to the documentation I should only create tokens when $type == 'example'. $type is never equal to my module's name. I guess the big question is how does Drupal know to call token_value with for my module?
MisterBigs
Any implementation of `hook_token_values()` is called as `hook_token_values($type, $object = NULL)`. If you call `token_replace()` as `token_replace($original, 'example', $form)` `example_token_values()` will get `$form` in its parameter `$object`. The same is true if you call `token_replace_multiple()` with `array('example' => $form)` as second parameter.
kiamlaluno
In what function do I call token_replace() or token_replace_multiple()? I need my form's values to go into a Send Tokenized E-mail action. Also, I'm running Token v. 6.x-1.14
MisterBigs
@MisterBigs: You call those functions where you need the tokens to be replaced; the problem is that the function that calls `token_replace()` should have access to the form values too. If the function were you need to replace the tokens is not the same function that access to the variable `$form`, then you need to find a way to pass the value of `$form` to the function that calls `token_replace()` (or `token_replace_multiple()`).
kiamlaluno
Thanks for the help. I'm going to go with the PHPMailer module instead. I've been looking everywhere for help with Tokens and I've have not been able to do do what I need it to do.
MisterBigs

related questions