When the user logout, the number of people online will be lost
-
Hi
There is an important issue with your plugin. When a user logout, all guest users are removed from the sftrack table
the reason:
You used the following actions and functions to display users’ statistics when login and out:add_action('wp_login', 'sp_track_login'); add_action('wp_logout', 'sp_track_logout'); function sp_track_login() { # if user was logged as guest before logging in, remove the guest entry $ip = sp_get_ip(); SP()->DB->execute("DELETE FROM ".SPTRACK." WHERE trackname='".$ip."'"); } function sp_track_logout() { global $current_user; sp_set_last_visited($current_user->ID); SP()->DB->execute("DELETE FROM ".SPTRACK." WHERE trackuserid=".$current_user->ID); # clear the users search cache SP()->cache->delete('search'); }
The action used for user logout is incorrect with your function.
You should use the following action:
add_action('clear_auth_cookie', 'sp_track_logout', 10);
Otherwise the return value of the $current_user->ID is 0 or false, so all online guests will be removed from the “sptrack” table
wordpress: latest version
simple press: latest version
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘When the user logout, the number of people online will be lost’ is closed to new replies.