Forums

Hooking into wp_logout... current_user? (2 posts)

  1. Elieka
    Member
    Posted 1 year ago #

    Hey all. I'm working on writing a dashboard widget and part of what I need involves the need for a way to tell when the current user last logged in.

    There are plugins out there that track the last time anyone logs in... But this is not what I need. There are multiple admins to this blog and I want to be able to track and display content that is new to each individual user.

    The problem I'm experiencing right now is that when I hook into wp_logout and use get_currentuserinfo() on the $current_user global, the user info is already cleared for the logout so I can't grab the ID to use it to update the user_meta.

    To be clear, I don't want to log this when they login. It would defeat the purpose of what I'm trying to do.

    So, questions:
    1. Is there an elegant way to get the ID of the current user in the process of logging out?
    2. Is there somewhere I can hook into during the logout process BEFORE the user information is cleared?

    Thanks all.

  2. Jackson
    Member
    Posted 1 year ago #

    wp_logout is a pluggable function so you can redefine it to suit your needs.

Topic Closed

This topic has been closed to new replies.

About this Topic