When calling user_save inside hook_user_login, if the $edit array is used (which you should use when using hook_user_insert)
Login will be aborted when using the drupal log in form since drupal is trying to save the full form_state to the user.
When calling user_save inside hook_user_login, if the $edit array is used (which you should use when using hook_user_insert)
Login will be aborted when using the drupal log in form since drupal is trying to save the full form_state to the user.
Comments
Comment #2
vinay15Hi nicxvan,
The documentation about hook_user_login clearly states that $edit is "The array of form values submitted by the user." which is same as $form_state. So, I think this might not get changed.
And while using user_save in hook_user_login, you can use $edit['user'] object to save user data.
Thanks,
Vinay
Comment #3
vinay15Comment #4
nicxvan commentedThanks for the tip on $edit['user']
It seems the edit array here is used differently than other API's though and it performs more like a form_state as the documentation says, why would we not document it in the function call to prevent confusion.
Comment #5
vinay15Yes, I totally agree with you that it should be stated as $form_state rather than $edit, but there might be some reason why it is called as $edit in the first place.
Comment #6
nicxvan commentedIs there someone I can message that would know? Or should I comment on that api entry?
Comment #7
marcaddeo commentedI would agree with nicxvan here. I found the documentation was a bit unclear because of that as well and spent quite some time trying to figure out why it wasn't working, only to find out that $edit is actually $form_state.
I think updating the documentation makes sense to make it clear.
Comment #8
vinay15Yes, commenting on that api would also get some replies and there are people on IRC who will also reply to the query.
Comment #10
avpadernoComment #11
poker10 commentedI thinks this is now a duplicate of #3279652: Erroneous signature and documentation for user_login_finalize() and hook_user_login(), where a MR is prepared. Thanks for working on this, I am closing this issue as there is no patch to review. We will assign credits if the second issue is committed.