I have to add some data to body of my content type, how do I add it in hook_node_save. I tried adding it like shown below but it's not getting saved.

function mymodule_node_save($node) {
$node->body = 'test string';

Also when I do dsm($node) in the above function, the $node->body doesn't contain the string I added.


1 Answer 1


There's no such hook as hook_node_save(), you're probably looking for hook_node_presave()

Act on a node being inserted or updated.

Also, the nody body is a field so you have to treat it as such when assigning values:

function mymodule_node_presave($node) {
  $node->body[LANGUAGE_NONE][0]['value'] = 'test string';

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.