Using node_save in drupal 7 with CCK fields

If you are a Drupal developer, you probably know how to save a node using node_save() function. I am coming across saving node with CCK fields so often. I had no any issue while on the D6. First time on the Drupal 7, it hurt me lot leaving CCK field blank when saving where I used the same technique as D6. It might help some one of you…


Drupal CCK

Drupal 6 way of saving CCK

This steps works fine for Drupal 6.

The Drupal 7 version of above script is follow..

If you look at the code, you will find a new array key “und”. Drupal 7 need this to save the custom fields. So what the heck is this “und”. do not jump to google search. This is just language code only..

2 thoughts on “Using node_save in drupal 7 with CCK fields

Leave a Reply

Your email address will not be published. Required fields are marked *


Please wrap all source codes with [code][/code] tags.

This site uses Akismet to reduce spam. Learn how your comment data is processed.