我需要重定向用戶角色的網址。drupal 6:自定義用戶角色的重定向管理網址
URL來源:http://www.example.com/admin
URL TO:http://www.example.com/admin/content/filter
用戶角色:例如管理員
所以,當用戶(例如管理員角色)登錄到管理面板的example.com/admin網址,他不會看到訪問拒絕頁面,但重定向到內容/過濾器作爲默認登錄網址。
鑑賞幫助!非常感謝!
我需要重定向用戶角色的網址。drupal 6:自定義用戶角色的重定向管理網址
URL來源:http://www.example.com/admin
URL TO:http://www.example.com/admin/content/filter
用戶角色:例如管理員
所以,當用戶(例如管理員角色)登錄到管理面板的example.com/admin網址,他不會看到訪問拒絕頁面,但重定向到內容/過濾器作爲默認登錄網址。
鑑賞幫助!非常感謝!
如果你想從代碼做一個自定義的模塊中,你可以實現hook_menu_alter()
和調整進入回調函數使用自定義的控制裝置:
function yourModule_menu_alter(&$items) {
// Override the access callback for the 'admin' page
$items['admin']['access callback'] = 'yourModule_admin_access_override';
}
在這種重寫,執行標準訪問檢查並返回結果,但增加在檢查的具體作用和重定向相反,如果需要的話:
function yourModule_admin_access_override() {
global $user;
// Does the user have access anyway?
$has_access = user_access('access administration pages');
// Special case: If the user has no access, but is member of a specific role,
// redirect him instead of denying access:
if (!$has_access && in_array('example-admin', $user->roles)) {
drupal_goto('admin/content/filter'); // NOTE: Implicit exit() here.
}
return $has_access;
}
(注:未經測試的代碼,謹防錯別字)
您將不得不觸發菜單註冊表的重建,以便獲取菜單更改。
您應該考慮使用規則模塊(http://drupal.org/project/rules)。 Rules模塊允許您在登錄到任意URL時發出重定向。您也可以在發出重定向之前檢查用戶的角色等情況。