Community

create a node on new user account, it is the good way ?

Hello,
I need to create a node when a account user is created if the role of this account is "student".
First I have tried with rules, but is very complicated because I need to take a date field present in the user form and copy it in the node, so i decided to do by code, but I'm not shure it is the good way.
In a module I have put :
hook form_alter : if the form is 'user_register_form'
$form['actions']['submit']['#submit'][] = 'bilan_formTools_user_register_submit';

in this function I have pasted all the original function (70 lines) : user_register_submit($form, &$form_state)
At the end I have pasted the code to create the node :
$node = new stdClass();
.....
node_save($node);

it works
but I just want to know if the good way, because after that I need to modify the node created when the account is modified and the date is changing.

Thanks a lot.

Comments

What do you need the node

What do you need the node for?

the node is an event of a

the node is an event of a student project (type of content : event administrator).
When the administrator create a new student account, he has to fill a end date project.
Automatically, the date appears in the project student timeline (view timeline with all the event contents).
The student can add event for his project (type of content : event student).
Thanks for your help.

Can you give me your feeling

Can you give me your feeling about this?
Regards,

The way you are doing it

The way you are doing it works, I would just stick with that approach.