Active
Project:
Messaging Send To
Version:
6.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
14 May 2009 at 02:26 UTC
Updated:
25 Jun 2009 at 16:19 UTC
I'd like to have my own custom module alter the message composition in _messaging_sendto_compose(). I don't think this is doable right now but let me know if it is. messaging_sendto should make a hook available that my module could implement. It should make available all the parameters ($method, $destination, $values, $preview) and allow me to alter the $message array.
To give you an idea of what I was doing, I wanted to alter some message params depending on data in an extra field that I added to the form, and also add some attachments:
if (isset($values['gateway'])) {
$message['params']['sms'] = $values['gateway'];
}
if (!empty($values['node']->files)) {
$message['attachments'] = $values['node']->files;
}
if (!empty($values['node']->field_image)) {
foreach ($values['node']->field_image as $file) {
$message['attachments'][] = (object) $file;
}
}
Comments
Comment #1
mfbQuestion about how to implement this: Should we store the $values (which includes $values['node']) in the $message object, so contrib modules have access to the sendto "context" and can use message_alter() to alter the message? This might be preferable to adding a new hook as I suggested above.
Comment #2
David Goode commentedHey, attachments are in the works in messaging in general, I'll try to look into utilizing that functionality for this module. You could also try hook_message_alter() or similar on the messaging side of things.
David
Comment #3
mfbWhen altering the message, I need access to the form values (including the node object, and also any custom form fields I am adding via form_alter). Seems like I need either a new hook, or for messaging_sendto to make the form values available somewhere in the message object.