有機グループのコンテキストでは、グループのメンバーではないユーザーがグループの投稿をそのグループに追加できないようにするモジュールを作成しています。
私のモジュールは現在、必要な権限を設定し、ユーザーが権限を持っているかどうかを検出します。
そのため、ユーザーがグループページを表示しているときに、標準リンクを無効化/削除してグループ投稿を作成したいと思います。
有機グループのコンテキストでは、グループのメンバーではないユーザーがグループの投稿をそのグループに追加できないようにするモジュールを作成しています。
私のモジュールは現在、必要な権限を設定し、ユーザーが権限を持っているかどうかを検出します。
そのため、ユーザーがグループページを表示しているときに、標準リンクを無効化/削除してグループ投稿を作成したいと思います。
この方法を試してください。
function mymodule_menu_alter(&$items) {
global $user;
// Perform code for finding out users permissions.
// lets suppose we set true or false to $restricted after all
if ($restricted && isset($items['node/add/yourtype'])) {
$items['node/add/yourtype']['access arguments'] = FALSE;
// or unset($items['node/add/yourtype']) to remove item for user
}
}
私が正しく理解していれば、特定のユーザーにコンテンツタイプを作成させたくないでしょう。
したがって、手順は次のとおりです。
1)メニューフックを作成します。
// Here we make sure if the user goes to for creating this node type
// we can use the appropriate call back function to stop it.
function yourmodoule_menu() {
$items = array();
$items['node/add/page'] = array(
'page arguments' => array('yourmodule_additional_actions'),
'access arguments' => array('administer create content')
);
}
2)次に、アクセス許可フックを作成して、特定のユーザーのみがこのアクセス許可を持っていることを確認します。
// drupal will only allow access to to path 'node/add/page' with people
// who have access given by you.
function yourmodule_permission() {
return array(
'add content' => array(
'title' => t('Administer create conent'),
'description' => t('Perform administration tasks and create content')
)
)
}
3)権限を持つユーザーのためにコードを記述します。
// Only affter they have this permisson drupal will allow them access
// to the below function.
function yourmodule_additional_actions() {
// this code will only execute if the user has the permission
// "Administer create conent"
}