I need to perform some cleanup after a user logged out, so I added a wp_logout action hook. Problem is, wp_get_current_user() already returns null if called from within the wp_logout action hook. How do I get the logging out users userid inside a wp_logout action hook?
Leave a Reply
You must be logged in to post a comment.
How about hooking
'clear_auth_cookie'
with the cleaning you need to do? If you need even more depth, you can outright replacewp_clear_auth_cookie()
, but that can get into issues where it will conflict with other plugins, so avoid that if possible.Update (previous edit contained inaccuracy):
As source code suggests too, you can now use
use this in plugin main file