- This topic has 0 replies, 1 voice, and was last updated 4 years, 4 months ago by .
Viewing 1 post (of 1 total)
Viewing 1 post (of 1 total)
- You must be logged in to reply to this topic.
WordPress Membership Plugin
Simple Membership Plugin › Forums › Simple Membership Plugin › run function just before user logout
Tagged: Logout, swpm_logout
Hi,
I need to register the logout datetime in my own database table when the user close its session. I try to use something like this:
add_action('swpm_logout', 'my_logout_function');
function my_logout_function() {
$member_id = SwpmMemberUtils::get_logged_in_members_id();
// UPDATE my_table SET logout_date = current_time( 'mysql' ) WHERE my_user = $member_id;
//Specify the URL that you want to redirect to
$url = "http://www.example.com/after-logout-page";
wp_redirect($url);
exit();
}
But the SwpmMemberUtils::get_logged_in_members_id() only returns ‘User is not logged in.’
I understand that when the swpm_logout hook is executed, the user is already logged out. So how can I retrieve the id of the user who is logging out? Is there a hook that runs just before the session is closed?
Thank you.