我创建了模块,现在我想在该模块上设置权限,以便一些用户可以看到该字段。我在谷歌和stackoverflow上搜索,但我没有得到我需要的正确答案。我的代码如下
function downloaded_menu() {
$items['user/%user/downloaded_poems'] = array(
'title' => 'Downloaded Poems',
'page callback' => 'downloaded_content_page',
'access arguments' => array('poet downloaded work'),
'type' => MENU_LOCAL_TASK,
'weight' => 11,
);
return $items;
}现在,我想向特定用户授予权限。他们只能看到。
发布于 2012-10-30 01:07:58
为此,您必须使用hook_permission。
代码示例:
function downloaded_permission()
{
return array(
'poet downloaded work' => array(
'title' => t('poet downloaded work'), // the title to be shown in the permissions page
'description' => t('poet downloaded work'), // the description to be shown in the permissions page
'restrict access' => FALSE,
),
);
}然后转到权限页面,将权限授予所需的角色。
希望这能帮到你。穆罕默德。
https://stackoverflow.com/questions/13120540
复制相似问题