Can someone explain “access arguments” in Drupal?

后端 未结 3 1456
悲哀的现实
悲哀的现实 2020-12-15 08:04

Can someone explain \"access arguments\" in Drupal? Trust me I have tried Googling it but I am just not getting a clear grasp.

3条回答
  •  一向
    一向 (楼主)
    2020-12-15 08:45

    in /admin/user/permissions you will see lots of access options. they come from drupal modules, and lets the site administrator distribute specific permissions to user roles (drupal provides 'anonymous' and 'registered' roles by default). modules declare them through hook_perm and they are as easy to use as:

    function mymodulename_perm {
    return array('use custom feature', 'use the other custom feature');
    }

    and they will show up there, ready to be used. now, in any function of yours, you can check for user access through user_access which is just as easy to use:

    if (user_access('use custom feature')) {
      //do something
    }

提交回复
热议问题