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

nicxvan created an issue. See original summary.

Vinay15’s picture

Hi 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

Vinay15’s picture

Assigned: Unassigned » Vinay15
Status: Active » Closed (won't fix)
nicxvan’s picture

Status: Closed (won't fix) » Needs review

Thanks 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.

Vinay15’s picture

Yes, 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.

nicxvan’s picture

Is there someone I can message that would know? Or should I comment on that api entry?

marcaddeo’s picture

I 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.

Vinay15’s picture

Yes, commenting on that api would also get some replies and there are people on IRC who will also reply to the query.

Version: 7.43 » 7.x-dev

Core issues are now filed against the dev versions where changes will be made. Document the specific release you are using in your issue comment. More information about choosing a version.