Is it at all possible to get a user’s ID in a function right at the point of log out?
I tried to hook it to wp_logout
, but it just returns null when trying to get the user’s info.
I’m wondering if there is another hook that comes before wp_logout
destroy’s the session that would enable me to capture the ID and do something with it.
I simply want to update a user meta field with the time of logout.
Is there any way of doing this?
I think I figured this one out.
I had misread this answer and hooked the function I wrote to
wp_clear_auth_cookie
(actually a function itself!) instead ofclear_auth_cookie
(the real hook), so that wasn’t working. But now using the real hook, I think it might be. Correct me if I’m wrong.Below is the function with the hook.