Make WordPress Core

#49533 closed defect (bug) (fixed)

Add user ID to wp_logout action

Reported by: TimothyBlynJacobs Owned by: SergeyBiryukov
Milestone: 5.5 Priority: normal
Severity: normal Version: 5.3
Component: Users Keywords: good-first-bug has-patch
Focuses: Cc:


As pointed out by @figureone, after #35488, the logged out user's id is no longer accessible when the wp_logout action is fired.

I think it would be a good idea to get the current user's id before starting the logout and then passing that id to the logout filter. As @figureone pointed out, the clear_auth_cookie hook can be used as a stop-gap, but I think the change is still valuable since the two aren't equivalent actions. Auth cookies are cleared in other places, not just when the user is logging out.

Attachments (2)

49533.patch (483 bytes) - added by rebasaurus 21 months ago.
Added pre_wp_logout action before used is logged out.
49533.2.diff (918 bytes) - added by donmhico 20 months ago.

Download all attachments as: .zip

Change History (8)

#1 @figureone
21 months ago

This is actually what we did manually, after a report of an incompatibility with another plugin (User Switching) after we switched from the wp_logout to clear_auth_cookie hook. Now we grab the user ID in clear_auth_cookie, and then reference it in wp_logout.

Adding user ID as a param to wp_logout would simplify this for us.

#2 @johnbillion
21 months ago

  • Milestone changed from Awaiting Review to 5.5

21 months ago

Added pre_wp_logout action before used is logged out.

#3 @rebasaurus
21 months ago

  • Keywords has-patch added; needs-patch removed

20 months ago

#4 @donmhico
20 months ago

49533.2.diff is different compared to 49533.patch as it tries to follow the suggested approach by @TimothyBlynJacobs.

#5 @SergeyBiryukov
20 months ago

  • Owner set to SergeyBiryukov
  • Status changed from new to reviewing

#6 @SergeyBiryukov
20 months ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In 47553:

Users: Pass the ID of the user that was logged out to the wp_logout action.

Props donmhico, figureone, TimothyBlynJacobs, rebasaurus.
Fixes #49533.

Note: See TracTickets for help on using tickets.