因為程式中有使用到user_access()來檢查權限,此函數必須帶入權限名稱的字串。
例如:
if (user_access('edit page content', $user)) {
print '有權限' ;

但是不確定權限名稱,所以在網路上搜尋解答。
網路上有一段語法可以把權限秀出來,我把這段語法加在區塊中,果然就解決了。
從秀出來的訊息中,就可以找到權限名稱。
foreach (module_list(FALSE, FALSE, TRUE) as $module) {
print_r($module);
if ($permissions = module_invoke($module, 'permission')) {
print_r($permissions);
}
}

arrow
arrow
    全站熱搜

    keven 發表在 痞客邦 留言(0) 人氣()