On 'insert' we call the hook_user only after the user object is fileld. But 'update' is called before that and it's good because your module may want to update the account before saving. But if you want to reuse the user object for some reason then a symmetric op is needed for update, too.

CommentFileSizeAuthor
update_post.patch350 byteschx

Comments

killes@www.drop.org’s picture

+1, but "update post" sounds a bit strange.

drumm’s picture

Status: Reviewed & tested by the community » Needs review

How about 'after_update'? (Naming convention borrowed from #after_build.)

chx’s picture

I am fine with either. We had 'form post' at one time. Also, 'post update' or 'after update' works, too.

drumm’s picture

Status: Needs review » Fixed

Committed to HEAD with after_update.

Please document in hook_user() in contrib.

chx’s picture

Done.

moshe weitzman’s picture

Sorry, I just saw this. Can we attempt to maintain consistency with nodeapi hooks? Lets compare the two of them as of today:

NODE
validate => submit => insert/update

USER
validate => => insert/update => after_update

I propose we standardize like:

validate => submit -> insert/update => after_update

If you wantt omess with the object before submission, you use the submit operation. if hyou want the operation after the node is all saved tothe DB, use after_update ... there is a long standing request for nodes to have this after_update hook so we will be helping them too.

chx’s picture

Status: Fixed » Active

reopening because Moshe is right (not that it surprises anyone).

RobRoy’s picture

Version: x.y.z » 6.x-dev

I was looking for some type of after_insert for when new user accounts are created, but noticed that user_save() only calls after_update when updating a user (not for both insert/update operations) and there is no similar way to trigger something for after_insert. We can attach a custom #submit handler for any new user forms, but shouldn't we have some type of after_insert invoked in user_save()?

sun’s picture

Version: 6.x-dev » 7.x-dev
Status: Active » Fixed

Solved in D7 via #118345: Revamp hook_user_form/_register/_validate/_submit/_insert/_update

validate => submit => presave => insert/update

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.