We are using wordpress for your website development. User is active when user_status=2 and user is inactive if user_status=0. Then what is the meaning of user_status=1.
Please provide your valuable suggestions.
Here are what each user_status means:
user_status = 0 => false or normal status
user_status = 1 => User marked as spammer
user_status = 2 => User pending (user account not activated yet)
https://wordpress.org/support/topic/what-is-the-status-of-user_status
The user_status field is effectively a dead record in the database. It's been that way for some time.
You could certainly make use of it for your own purpose, but as it is a sort of deprecated or unusued element, it's always possible it will be dropped from a future version of WordPress. Or even be put back to work.
Unfortunately, WordPress doesn't provide native online/offline user status methods. You'll have to implement it by yourself. Some ideas how to implement it right, could be found in that topic: https://wordpress.stackexchange.com/q/34429/44533
Another option is to use some 3rd-party plugin ( I can't advice any...).
In my own solution, I'm creating user_login
custom filed in wp_usermeta table, to check user status.
//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 it helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With