I have created a content type called 'inquiry.' I am using the rules module to send an email after submitting an inquiry. My requirement is to get the node id before it is saved. I need to generate a link from that node id so the inquiry handler can view the inquiry by clicking on that link.
You can use hook_nodeapi presave option to get node content before saving the node.
Example :
function MODULENAME_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
switch ($op) {
case 'presave':
print $node->nid;
exit;
break;
}
}
-
i have not created custom module , so what should i write in place of MODULENAME ..??? – 007Ketul Aug 3 '12 at 9:18
-
Karthi would reply "any name you want". But make sure that it's any string that can be used as a function name. But usually we use a lowercase short name for the module. it should be used in other hooks, in .info file name and event better in the module's folder name. – AyeshK Aug 3 '12 at 10:28
-
5This will not work ofr newly created nodes. On node creation $node->nid will not be set until the node is actually saved in the database. This will only works when an existing node is updated. – Pierre Buyle Aug 3 '12 at 12:44