Drupal 7 页面在限制drupal后呈现
我在drupal 7中使用自定义模块将角色限制为url。代码如下:Drupal 7 页面在限制drupal后呈现,drupal-7,Drupal 7,我在drupal 7中使用自定义模块将角色限制为url。代码如下: <?php // Implements hook_init() function restrict_access_init() { $restrictions = restrict_access_restrictions(); global $user; foreach ($restrictions as $path => $roles) { // See if the curr
<?php
// Implements hook_init()
function restrict_access_init() {
$restrictions = restrict_access_restrictions();
global $user;
foreach ($restrictions as $path => $roles) {
// See if the current path matches any of the patterns provided.
if (drupal_match_path($_GET['q'], $path)) {
// It matches, check the current user has any of the required roles
$valid = FALSE;
foreach ($roles as $role) {
print implode("','",$user ->roles);
if (in_array($role, $user->roles)) {
$valid = TRUE;
break;
}
}
if (!$valid) {
drupal_access_denied();
}
}
}
}
function restrict_access_restrictions() {
// This array will be keyed by path and contain an array of allowed roles for that path
return array(
'path/path' => array('admin'),
);
}
?>
这确实很好地限制了访问,但它会在页脚后呈现未设置样式的页面
你知道为什么会这样吗?
我现在对此束手无策。我需要添加模块&u invoke\u all('exit');退出();在drupal_访问_拒绝()下 e、 g
我找到了答案,我需要添加模块&u invoke&u all('exit');退出();在drupal_访问_拒绝()下;
drupal_acess_denied();
module_invoke_all('exit');
exit();