Prevent node from being saved So, this seems like a rather simple task but I've been stuck on it for a while.

I need either in hook_node_presave or in hook_node_submit (but NOT in hook_node_validate) to check for a field value in a node and according to that value choose whether or not to cancel the node saving procedure.

How do I do that? (The canceling part, not the checking part ;) )
I've found that the best way is to just thrown an error during presave. Here's a simple example:

function mymodule_node_presave($node){
  if(empty($node-&gt;title)){
    throw new Exception('Error saving node: Title cannot be empty');
  }
}


The node_save() function has a try...catch block wrapping the presave step that will catch the exception.

The advantage of this over drupal_goto() is that, if you're importing multiple nodes, it will skip the current node and proceeed to the next one. This is great if you're using something like the Feeds module. In contrast drupal_goto() will exit immediately and may interfere with other steps in the request or cron, which will break importing multiple nodes.