2
我已經安裝了模塊隱藏塊 - http://drupal.org/project/formblock(啓用在塊節點創建形式呈現)Drupal的 - 用PHP代碼
我已經啓用它對於特定的內容類型,然後暴露該塊,以顯示何時查看有機組節點。
我想要做的就是隱藏該塊,如果當前登錄的用戶不是正在查看的有機組節點的作者。 i.o.w我只想讓有機組作者看到該塊。
在此先感謝:)
我已經安裝了模塊隱藏塊 - http://drupal.org/project/formblock(啓用在塊節點創建形式呈現)Drupal的 - 用PHP代碼
我已經啓用它對於特定的內容類型,然後暴露該塊,以顯示何時查看有機組節點。
我想要做的就是隱藏該塊,如果當前登錄的用戶不是正在查看的有機組節點的作者。 i.o.w我只想讓有機組作者看到該塊。
在此先感謝:)
您可以使用「PHP block visibility settings」,實現你想要的這裏。使用PHP,您可以查詢數據庫,並檢查登錄用戶是否與在有機組中創建節點的用戶相同。
有an example已經對我已經適應drupal.org(您可能需要定製此進一步) -
<?php
// check og module exists
if (module_exists('og')){
// check user is logged in
global $user;
if ($user->uid) {
// check we've got a group, rights to view the group,
// and of type "group_type" - change this to whichever group you want to restrict the block to
// or remove the condition entirely
if (($group = og_get_group_context()) && node_access('view', $group) && ($group->type == 'group_type')) {
// check current user is a team admin as they should get access
if (og_is_node_admin($group)) {
return TRUE;
}
// check to see if the current user is the node author
if (arg(0) == 'node' && is_numeric(arg(1))) {
$nid = arg(1);
$node = node_load(array('nid' => $nid));
if ($node->uid == $user->uid) {
return TRUE;
}
}
}
}
}
return FALSE;
?>