[wp-trac] [WordPress Trac] #35488: wp_logout() not working as it should

WordPress Trac noreply at wordpress.org
Tue Jan 29 12:32:42 UTC 2019

#35488: wp_logout() not working as it should
 Reporter:  sebastian.pisula  |       Owner:  (none)
     Type:  defect (bug)      |      Status:  reopened
 Priority:  normal            |   Milestone:
Component:  Users             |     Version:
 Severity:  normal            |  Resolution:
 Keywords:                    |     Focuses:
Changes (by roytanck):

 * status:  closed => reopened
 * resolution:  wontfix =>


 Bumped into this in a project today, and have taken the liberty of
 reopening the ticket.

 I'm writing a plugin that automatically logs a user out after a certain
 period of inactivity. To do this, I'm hooking into "admin_init", and if
 the user has been inactive for x minutes, I call wp_logout(). For this to
 work properly, all code running after "admin_init" should run as if the
 user is not logged in. Among other things, this will trigger the login
 modal in wp-admin.

 Considering that I just explicitly logged out the user,
 is_user_logged_in() especially should return false. Other functions that
 are affected are get_current_user() and wp_auth_check().

 Sebastian.pisula's patch works flawlessly for me on 5.0.3. It makes
 wp_logout() do what the function's name and description suggest.

 Please consider accepting this patch.

Ticket URL: <https://core.trac.wordpress.org/ticket/35488#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform

More information about the wp-trac mailing list