By tigrezno on
I want to save custom data in user.data table when a new account is created, but after all, i can't do it and there isn't information out there about it.
Do you know what is the way of achieving this?
I want to save custom data in user.data table when a new account is created, but after all, i can't do it and there isn't information out there about it.
Do you know what is the way of achieving this?
Comments
SOLVED
I used finally hook_user -> REGISTER, that isn't documented in drupaldocs.org.
Just add a hidden form with the variable to the registration form.
This Could Help Somebody Else Too
Hi, just wanted to add that if you look in profile.module, in the implementation of hook_user they also use the "register" value of $op for the hook, and later call profile_form_profile() in a switch block from both $op = 'register' and $op = 'form' (actually the parameter is called $type in the code but it's the same referred as $op in the docs).
Then the value of $_GET['q'] is compared to 'user/register' in profile_form_profile() to know if the user is registering or just editing the form.
I hope this helps in better understanding the power of using hook_user.
Regards!
Alexis Bellido - Ventanazul web solutions
Have the same issue
Have the same issue on D5.10. When I tried to add some data in hook_user on $op = 'insert'. Also, I am doing drupal_set_message() in the same $op = 'insert' with $user object, where I can see the field I have added with data. But if I reviewing this field after login under this username/password I do not see data in that field (but field exists, and is empty).
My issue is fixed!
I use user_save() to add data to $user object. Instead I should use $edit object, that is given to hook_user(). So now it is working, just use:
$edit['new_field'] = $new_field_data;I had similar needs with D6.
I had similar needs with D6. I wasn't sure how to set custom profile fields.
I got what I needed by adding a custom cck field to my user's profile called 'profile_notes' (go to User Management/Profiles) I made it hidden and only available to admins. Then with hook_form_alter I added my field as a hidden value. If I had data that was sensitive (e.g. 'this user is a bad kisser') I may have taken a different approach.
Note that I've used arg(0) to determine if ppl are on my custom signup form, the hook_page of which calls the user form and hook_menu sets up the callback. Now I've got a custom signup page and if people sign up through this page I flag them and send them some swag, in this case- a sticker: