Opened 15 years ago
Last modified 5 years ago
#12720 new defect (bug)
Delete user and hook confusion when deleting users in Multisite
Reported by: | andreasnrb | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.0 |
Component: | Users | Keywords: | needs-patch |
Focuses: | multisite | Cc: |
Description
Currently:
The hook wpmu_delete_user fires when deleting user in Super Admin->Users.
The hook remove_user_from_blog when deleting user under site Users->Authors & Users.
In standard WP:
The hook delete_user is called when deleting users it should be the same in MultiSite when deleting from Super Admin->Users.
Or add new hooks and deprecate previous.
delete_user_from_network for when deleting a user totally.
delete_user_from_site for when deleting a user from a specific site. This is hook also then fires in non-MultiSite mode since that then corresponds to one site.
Change History (7)
#4
@
11 years ago
Interesting note - wp_delete_user()
only removes the user from the current site if used in multisite. The user does not actually get deleted from the database. As it is, the hook delete_user
is somewhat misleading in its documentation.
There may be a way for us to clean this up before introducing new hooks or hook changes. We could move the multisite check up to the top and just bounce over to remove_user_from_blog()
. Or we could merge wp_delete_user()
and wpmu_delete_user()
. It'd be nice to think some of that out first before adding a hook in somewhere.
#5
follow-up:
↓ 6
@
11 years ago
wp_delete_user() only removes the user from the current site if used in multisite. The user does not actually get deleted from the database.
WP-CLI just ran into this. I'd be a huge fan of explicit core APIs for each behavior — wp_delete_user()
seems to do too much right now.
#6
in reply to:
↑ 5
@
11 years ago
Replying to danielbachhuber:
wp_delete_user() only removes the user from the current site if used in multisite. The user does not actually get deleted from the database.
WP-CLI just ran into this. I'd be a huge fan of explicit core APIs for each behavior —
wp_delete_user()
seems to do too much right now.
Seems like there might be a case for wp_remove_user()
here, especially if the user isn't actually getting deleted. No time like the present to draw a distinct line between the concepts of removal vs deletion.
Hey @andreasnrb, sorry about the wait!
delete_user
fires before anything happens inwp_delete_user()
wpmu_delete_user
fires before anything happens inwpmu_delete_user()
, which has a todo note wondering if we can merge withwpmu_delete_user()
remove_user_from_blog
fires before a user is removed from a site, which doesn't necessarily mean they are deleted.I think
delete_user
is enough here. We could probably think about moving it alongsidewpmu_delete_user
inwpmu_delete_user()
or figure out if a merge of the two functions is possible.