What is the value 1 in the wp_users user status field in wordpress CMS?

We use wordpress to develop your site. The user is active when user_status = 2, and the user is inactive if user_status = 0. Then what is the meaning of user_status = 1.

Please provide your valuable suggestions.

+7
wordpress
source share
4 answers

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.

+8
source share

From other threads, I see that user_status is actually a "dead" field. It remains in the wp_user table, but is no longer used by WP itself. Probably explains why wp_update_user does not touch it.

 global $wpdb; $wpdb->query('UPDATE wp_users SET user_status = 1 WHERE ID = '.$current_user->ID); 

FOR MORE http://codex.wordpress.org/Class_Reference/wpdb

+3
source share

You should add_user_meta use add_user_meta ( WP Codex ) and add a new field to your users table.

This seems like the cleanest way for me, and you won’t be surprised if user_status is removed from the database for some time in the future.

+1
source share

Maybe I'm late, but user_status is not dead, as it sounds, it is most often used on the network / multisite to mark the user as spam; -)

0
source share

All Articles