问题描述
我知道在 drupal 模块中使用它来指定只有匿名用户才能看到该模块.指定仅登录用户的回调是什么?
I know that is used in a drupal module to specify that only anonymous users can see that module. What would be the callback that specifies only logged in users ?
我有一个页面,我只想让登录用户访问.
I have a page that I only want accessible to logged in users.
谢谢
推荐答案
这是user_is_logged_in() 函数,它基本上检查用户的 ID ($GLOBALS['user']->uid) 是否大于零.
It is the user_is_logged_in() function, which basically checks that the user's ID ($GLOBALS['user']->uid) is greater than zero.
该函数将 uid 转换为布尔类型,并为任何登录的用户返回 TRUE,因为他们的 uid 为正数.Drupal 为匿名用户分配 uid 为 0,转换为 Boolean 时为 FALSE.
The function converts the uid into a Boolean type and returns TRUE for any user that is logged in, because they would have a uid that is a positive number. Drupal assigns anonymous users a uid of 0, which is FALSE when converted into a Boolean.
这篇关于访问回调 user_is_anonymous 的反义词是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!