wordpress CMS中wp_users的用户状态字段中的1是什么意思? [英] what is the meaning of 1 in user status field of wp_users in wordpress CMS?
问题描述
我们正在使用 wordpress 来开发您的网站.当 user_status=2 时用户处于活动状态,如果 user_status=0 时用户处于非活动状态.那么user_status=1是什么意思.
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.
请提供您宝贵的建议.
推荐答案
https://wordpress.org/support/topic/what-is-the-status-of-user_status
user_status 字段实际上是数据库中的死记录.这种情况已经有一段时间了.
The user_status field is effectively a dead record in the database. It's been that way for some time.
你当然可以将它用于你自己的目的,但事实上一种不推荐使用或未使用的元素,它总是有可能的从未来版本的 WordPress 中删除.甚至被放回工作.
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.
不幸的是,WordPress 不提供原生的在线/离线用户状态方法.你必须自己实现它.可以在该主题中找到如何正确实施它的一些想法:https://wordpress.stackexchange.com/q/34429/44533
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
另一种选择是使用一些 3rd 方插件(我不能建议任何...).
Another option is to use some 3rd-party plugin ( I can't advice any...).
在我自己的解决方案中,我正在创建 user_login
自定义归档在 wp_usermeta 表,用于检查用户状态.
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");
}
希望能帮到你.
这篇关于wordpress CMS中wp_users的用户状态字段中的1是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!