简体   繁体   English

drupal仅允许访问经过身份验证的用户的内容

[英]drupal give permission to access a content to authenticated user only

I am using a drupal 6. I need to restrict access to certain pages to my site for only the authenticated users. 我正在使用drupal 6.我需要限制只访问经过身份验证的用户访问我网站的某些页面。 All these pages are having their own primary navigation parent menu, mouse hover on which it shows the sub menu to these pages. 所有这些页面都有自己的主导航父菜单,鼠标悬停在其上显示这些页面的子菜单。 Once user clicks on it, it should show the page content if user is authenticated otherwise should show "Access Denied". 用户点击后,如果用户通过身份验证,则应显示页面内容,否则应显示“拒绝访问”。

I tried to use Content Access module, though it restricts the access to the pages but it does not even show the menu link to anonymous user in menu list. 我尝试使用内容访问模块,虽然它限制了对页面的访问,但它甚至没有显示菜单链接到菜单列表中的匿名用户。

Is it possible to show menu in menu list, but on clicking on link it should show the access denied message of user is anonymous? 是否可以在菜单列表中显示菜单,但是点击链接时应该显示用户的访问被拒绝消息是匿名的?

There are 2 ways you can go about this, the field permissions module if you just want to limit to specific fields or you can make a PHP block, call global $user within it, and if the user's role doesn't match on the node type for who you need to be, then call drupal_access_denied() 有两种方法可以解决这个问题,即字段权限模块,如果您只想限制特定字段,或者您可以创建一个PHP块,在其中调用global $ user,以及用户的角色在节点上是否匹配输入你需要的人,然后调用drupal_access_denied()

http://api.drupal.org/api/drupal/includes!common.inc/function/drupal_access_denied/6 http://api.drupal.org/api/drupal/includes!common.inc/function/drupal_access_denied/6

The block method is going to be much more efficient because you won't have to configure a billion checkboxes if you have a lot of fields and because if you make the block within a custom module, it will be exportable easily to other Drupal sites. 块方法将更加高效,因为如果您有很多字段,则不必配置十亿个复选框,并且如果您在自定义模块中创建块,它将可以轻松导出到其他Drupal站点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM