WordPress.org

Make WordPress Core

Opened 3 months ago

Closed 2 months ago

#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:

Description

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 3 months ago.
Added pre_wp_logout action before used is logged out.
49533.2.diff (918 bytes) - added by donmhico 2 months ago.

Download all attachments as: .zip

Change History (8)

#1 @figureone
3 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.
https://github.com/uhm-coe/authorizer/commit/30d902be01f17d414fc18179cfb3e84a916499f4
https://github.com/uhm-coe/authorizer/issues/91

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

#2 @johnbillion
3 months ago

  • Milestone changed from Awaiting Review to 5.5

@rebasaurus
3 months ago

Added pre_wp_logout action before used is logged out.

#3 @rebasaurus
3 months ago

  • Keywords has-patch added; needs-patch removed

@donmhico
2 months ago

#4 @donmhico
2 months ago

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

#5 @SergeyBiryukov
2 months ago

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

#6 @SergeyBiryukov
2 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.