Run PHP when node and/or profile is updated? I wanted to run an external script when a user profile(2) is updated, and/or when a node is updated. I've added the code to the themes template.php, but no go.

What have I missed?

&lt;?php

$api_script_url = "http://www.aaa.com/test/test.php";
$msg = "File updated.";

// WHen a node is updated, be it new or old, update file.
function theme_node_update($node) {
    include($api_script_url."?q=".$node-&gt;nid);
    drupal_set_message($msg, 'status');
}

// WHen user profile2 profile is updated, be it new or old, file.
function theme_profile2_update($profile) {
    include($api_script_url."?q=".$profile-&gt;uid);
    drupal_set_message($msg, 'status');
}

?&gt;
Theming functions are the wrong place for something like that. To run some PHP code after an node or profile (thus entity) is updated you should use the Rules module or use the following hooks, hook_entity_insert, hook_entity_update