Created
February 7, 2011 17:00
-
-
Save zerolab/814716 to your computer and use it in GitHub Desktop.
Drupal: perform any action when a node is published
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Implementation of hook_nodeapi() | |
* Perform any action when a node is published | |
* Note: because no extra data added via $op = 'load', a node "reload" is necessary on presave | |
*/ | |
function mymodule_nodeapi(&$node, $op) { | |
if ($op == 'presave') { | |
if ($node->type == 'my_node_type' && $node->status == 1) { | |
// Get node state as of node_load() | |
$n = node_load($node->nid); | |
if ($n->status == 0) { | |
//the node has just been published. do something | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment