0

I am looking for some advice on how I might fetch an array with a list of links to node types the currently logged in user is allowed to create.

My client wants these links to populate a custom dropdown list which sits on the user profile page.

Just in case I don't manage to talk him out of it, I would like some technique/information to go on.

apaderno
  • 28,547
  • 16
  • 75
  • 90
sisko
  • 9,604
  • 20
  • 67
  • 139

1 Answers1

0

You will have to create a custom module. If you are creating your own module, this short snippet will give you an array ($types) with the links to content types the logged in user can create (D6). If the user cannot create any content types it will show a message:

<?php
  $types = array();
  foreach (node_get_types('types', NULL, TRUE) as $type) {
    if (node_access('create', $type->type)) {
      $types[$type->type] = l($type->name, 'node/add/' . str_replace('_', '-', $type->type));
    }
  }
  if (count($types) == 0) {
    drupal_set_message('You cannot create any content types!', 'warning');
  }
?>
Laxman13
  • 5,226
  • 3
  • 23
  • 27