Membership Plugin

WordPress Membership Plugin

  • Home
  • Documentation
  • Addons
  • Support
    • Quick Setup
    • Documentation
    • Premium Addon Support
    • Paid Support
    • Support Forum
    • Support Forum Search
    • Forum Login
    • Forum Registration
  • Contact

[Support request] run function just before user logout

Simple Membership Plugin › Forums › Simple Membership Plugin › run function just before user logout

Tagged: Logout, swpm_logout

  • This topic has 0 replies, 1 voice, and was last updated 4 years, 4 months ago by jaume.
Viewing 1 post (of 1 total)
  • Author
    Posts
  • December 2, 2021 at 10:36 am #23333
    jaume
    Participant

    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.

  • Author
    Posts
Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.
Log In

Please read this message before using our plugin.

Search

Featured Addons and Extensions

  • Membership Form Builder Addon
  • Member Directory Listing Addon
  • WooCommerce Payment Integration
  • Member Data Exporter Addon

Documentation

  • Documentation Index Page

Copyright © 2026 | Simple Membership Plugin | Privacy Policy