Possible Duplicate:
How to create new node programmatically, when a new user is created, in Drupal 7?

I am using Drupal-7 and Filedepot module. In Filedepot module a folder is created when we create node of filedepot folder content type.

I want to achieve that when any user registers in the site then one filedepot folder should be created.

Initially I used Rules module. And after registration I created a Rule to create a node of filedepot folder content type, but problem is that by using Rules I can't set some of the fields of content type. Node creation using Rules only creates node and sets title but it doesn't set the values of other fields.

Now I am planning to achieve it using other way, after user registers I want to create a node programmatically.

How can I customize Rule's node create action?

marked as duplicate by Chapabu, Clive, Anil Sagar, googletorp Oct 31 '12 at 11:15

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


This is how I managed it, and there was one problem regarding permission in folder creation. So I just assigned permission to create folder. and here is the code to create folder during user registration

function modulealter_user_insert(&$edit, $account, $category) {
    $node = new stdClass();
    $node->type = 'filedepot_folder';
    $node->language = LANGUAGE_NONE;
    $node->uid = $account->uid;
    $node->name = $account->name;
    $node->title = check_plain($account->name);
    $node->filedepot_folder_desc[LANGUAGE_NONE][0]['value'] = 'This is private folder of author user.';
    $node->parentfolder = 4;
    $node->inherit = 0;
    watchdog('filedepot',"New folder created @name - new filedepot folder created.", array('@name' => $account->title));

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