tnx all, this approach did the trick and saved me the hassle of creating extra value fields or tables.

HnLn

Brian Vuyk wrote:
Perhaps, on hook_api($op = 'presave'), load a copy of the node from the db, and check if the field has changed?

<?php

function yourmodule_nodeapi($op, &$node, $a3 = NULL, a4 = NULL) {

 if ($op == 'presave' && $node->type == 'your_type') {
   $old = node_load($node->nid);
if ($old->field_notify_by_email == 0 && $node->field_notify_by_email == 1) {
     // Send the changes via email.
   }
 }

}

?>

Henrique Recidive wrote:
2009/8/22 Hans Langouche <[email protected]>:
Hi there,

I'm working on a (node) profile system that has a checkbox to allow people to be informed by postal mail. If checked the system sends a mail with the details to a certain email address. Of course this email shouldn't be sent
every time  the profile is updated, but only when the checkbox was
previously unchecked (if it was checked allready, nothing should happen).

For the moment I'm thinking of creating a second (hidden) value to which I compare on 'update' and sync with the actual value after the check. But I'm thinking there must be an easier way, but can't find it in documentation or
by inspecting $node on 'update'.

Wouldn't it suffice adding a table (uid, sent) so when user checked
the checkbox it will check for a record in that table for the current
user, if not there, it will send system email and add a record to that
table?

That way, you know if the checkbox was checked previously and can
decide to display it defaulting to checked, or just hide the checkbox.

Henrique

Tnx,

HnLn



Reply via email to