I'm trying to figure out how to set a message using code?
The content of my mails are generated by another module but I want to use the Message and Message Notify to store the mails and send the mails, since it all fits in with the existing views/logs/history functionality.
But how can I set the message data properly in code?
I had a good look at the Examples in Message but I still miss some parts.
Case: I want to extend the "commerce_order_created" message type, so I added extra fields.
/**
* Implements custom function().
*/
function MYMODULE_message_insert_status($order, $communication) {
// Load data
$account = user_load($order->uid);
$message = message_create('commerce_order_created', array(), $account);
$message->message_commerce_order[LANGUAGE_NONE][0]['target_id'] = $order->order_id;
// Save reference to the order in the order reference field, and the
$wrapper = entity_metadata_wrapper('message', $message);
$now = time();
$wrapper->field_confirmation_date_created->set($now); // Custom fields to extend the commerce_order_created message type
$wrapper->field_confirmation_date_send->set($now); // Custom fields to extend the commerce_order_created message type
// Save message
$wrapper->save();
}
How can I set the data for?
Notify - Email subject
Notify - Email body
I loaded the message object and there these fields are not present?
Closed: outdated
2.5
Documentation
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.