0

I am trying to make a reservation system for equipment in a laboratory. People reserve equipment by creating "reservation" nodes. Some fields in the reservation node already have values, determined by the way the (registered) users reached the "form", and the values can´t be changed by them. I don´t want the registered users to have access to create the reservation node through the "Add content -> Create Reservation node" way. How to "hide" that option in the add content menu? (as they do have permission to create the reservation node)

0

If you want to simply get rid of link, you can go to http://example.com/admin/structure/menu/manage/navigation (substitute example with your domain) and remove the entry. This will not block direct access to http://example.com/node/add/reservation - if you are using custom module for that, consider blocking node creation in http://example.com/admin/people/permissions - your module can create nodes for them even when you remove "create node ... " permission there.

  • If I disable or move a create content link from the navigataion menu I get this error when I then try to directly access that node add form: "You have not created any content types yet." – rooby May 15 '15 at 5:59
  • @rooby if you have any content types, it's some Kong of bug. If you don't, it was a big that you was able to create content. Anyway, it's a matter for another question or bug report. – Mołot May 15 '15 at 6:02
  • 1
    Seemingly it is possibly related to this: drupal.org/node/550254 – rooby May 15 '15 at 6:49
  • @rooby well, major core bug is out of scope of my answer... Anyway, all I suggested was removing only one content type entry, not a whole node/add, so if someone will do what I wore and only what I wrote, he's safe. – Mołot May 15 '15 at 6:52
  • It also happens when you move just an individual item. You're right it doesn't really affect your answer but it might useful info to someone else that sees this. – rooby May 15 '15 at 7:51
0

In drupal 8, you can remove certain links from the /node/add page hook_preprocess_node_add_list():

function mymodule_preprocess_node_add_list(&$vars) {

  // Remove a few content types from /node/add page.
  $types_to_remove = [
    'dog',
    'cat',
    'fox',
    'rabbit',
  ];
  foreach ($types_to_remove as $type) {
    unset($vars['content'][$type]);
    unset($vars['types'][$type]);
  }
}

If you are using the admin_toolbar for drop-downs, you can remove links using hook_menu_links_discovered_alter().

function mymodule_menu_links_discovered_alter(&$links) {

  // Remove a few "node add" pages from admin menu.
  $types_to_remove = [
    'dog',
    'cat',
    'fox',
    'rabbit',
  ];
  foreach ($types_to_remove as $type) {
    unset($links['node.add.' . $type]);
  }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.