Drupal - What is the purpose of using node_submit() before node_save()?

node_submit() is a small helper function that makes sure the uid/author and creation date is set. Its main purpose is to map ->name to uid and ->date to created. Those two are used in the node edit/create form.

So if you set these two properties yourself anyway (and the validated flag but I haven't found anything that cares about it, likely some sort of left-over from earlier code), there is no need to call it.


you should also use node_object_prepare($node) which helps in doing the following: Provides the default values for the status, promote, sticky, and revision flags. These values are type specific if $node->type is defined, and can be modified as required.

Tags:

Nodes