Can someone explain “access arguments” in Drupal?

后端 未结 3 1460
悲哀的现实
悲哀的现实 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条回答
  •  旧时难觅i
    2020-12-15 08:41

    Access arguments are the arguments passed to the function that checks if a user has access to a menu.

    Given a menu callback definition as the following

      $items['blog/feed'] = array(
        'title' => 'RSS feed',
        'page callback' => 'blog_feed',
        'access callback' => 'custom_module_blog_access',
        'access arguments' => array('feed'),
        'type' => MENU_CALLBACK,
      );
    

    The function custom_module_blog_access() will be called as custom_module_blog_access('feed'). If the function returns TRUE, then the user will be given access to the menu callback; differently, the user will see the error 403 page (access denied). Normally, the access callback is not defined, and by default Drupal will use user_access().

提交回复
热议问题