https://wordpress.org/support/topic/what-is-the-status-of-user_status
The user_status field is actually a dead record in the database. This has been the case for some time.
You could use it for your own purposes, but since this is a kind of outdated or unusual item, you can always be removed from a future version of WordPress. Or even get back to work.
Unfortunately, WordPress does not provide native state methods for online / offline users. You will have to implement it yourself. Some ideas on how to exercise this right can be found in this thread: https://wordpress.stackexchange.com/q/34429/44533
Another option is to use a third-party plugin (I can not advise anyone ...).
In my own solution, I create a user_login custom registered in the wp_usermeta table to check the status of the user.
//Creating hooks for login/logout actions: add_action('clear_auth_cookie', array('WP_Plugin_Template','set_user_logged_out'), 10); add_action('wp_login', array('WP_Plugin_Template','set_user_logged_in'), 10, 2); //When hook is triggered, I'm using user_meta to update user status: function set_user_logged_in($user_login, $user) { if(get_user_meta($user->ID, "logged_in", true) !== "true") if(!update_user_meta($user->ID, 'logged_in', 'true')) wp_die("Failed to add usermeta ", "Fatal"); } function set_user_logged_out() { $user = wp_get_current_user(); if(get_user_meta($user->ID, "logged_in", true) !== "false") if(!update_user_meta($user->ID, 'logged_in', 'false')) wp_die("Failed to add usermeta ", "Fatal"); }
Hope this helps.
Samuel
source share