what is the meaning of 1 in user status field of wp_users in wordpress CMS?

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.

Related posts

Leave a Reply

6 comments

  1. 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.

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

    Seems like the cleanest way to me and you won´t be surprised, if user_status gets dropped from the database some time in the future.

  3. 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)