wordpress CMS中wp_users的用户状态字段中的1是什么意思?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/30160327/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 11:05:50  来源:igfitidea点击:

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

wordpress

提问by chandra sekhar

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.

我们正在使用 wordpress 进行您的网站开发。当 user_status=2 时用户处于活动状态,而当 user_status=0 时用户处于非活动状态。那么user_status=1是什么意思。

Please provide your valuable suggestions.

请提供您宝贵的建议。

回答by Samuel

https://wordpress.org/support/topic/what-is-the-status-of-user_status

https://wordpress.org/support/topic/what-is-the-status-of-user_status

The user_status field is effectively a deadrecord 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.

user_status 字段实际上是数据库中的记录。这种情况已经有一段时间了。

您当然可以将它用于自己的目的,但由于它是一种已弃用或未使用的元素,因此它总是有可能从 WordPress 的未来版本中删除。或者甚至被放回去工作。

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

不幸的是,WordPress 不提供原生的在线/离线用户状态方法。你必须自己实现它。一些如何正确实施的想法,可以在该主题中找到:https: //wordpress.stackexchange.com/q/34429/44533

Another option is to use some 3rd-party plugin ( I can't advice any...).

另一种选择是使用一些 3rd-party 插件(我不能建议任何......)。

In my own solution, I'm creating user_logincustom filed in wp_usermetatable, to check user status.

在我自己的解决方案中,我user_loginwp_usermeta表中创建自定义文件,以检查用户状态。

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

希望能帮助到你。

回答by channasmcs

From other threads I see that user_status is effectively a "dead" field. It remains in the wp_user table, but isn't used by WP itself for anything anymore. Probably explains why wp_update_user doesn't touch it.

从其他线程我看到 user_status 实际上是一个“死”字段。它保留在 wp_user 表中,但 WP 本身不再用于任何事情。可能解释了为什么 wp_update_user 不碰它。

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

更多 http://codex.wordpress.org/Class_Reference/wpdb

回答by Ryan S

I might be late here but the user_status is not dead as it sounds, it is used mosty in network/multisite to mark user as spam ;-)

我可能会迟到,但 user_status 并没有像听起来那样死掉,它主要用于网络/多站点以将用户标记为垃圾邮件 ;-)

回答by flomei

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

您可能应该使用add_user_metaWP Codex)并向您的用户表添加一个新字段。

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

对我来说似乎是最干净的方式,如果user_status将来某个时候从数据库中删除,您不会感到惊讶。

回答by Pravin Work

The user_status is not dead as it sounds, it is used mostly in network/multisite to mark the user as spam or ham.

This field is mostly used in multisite

user_status 听起来并没有死,它主要用于网络/多站点以将用户标记为垃圾邮件或火腿。

该字段主要用于多站点

https://developer.wordpress.org/reference/functions/update_user_status/

https://developer.wordpress.org/reference/functions/update_user_status/

回答by kuroyza

Here are what each user_status means:

以下是每个 user_status 的含义:

user_status = 0 => falseor normal status

user_status = 1 => User marked as spammer

user_status = 2 => User pending(user account not activated yet)

user_status = 0 => false或正常状态

user_status = 1 => 用户标记为垃圾邮件发送者

user_status = 2 => 用户待处理用户帐户尚未激活