Drupal permitted node types custom dropdown

118 Views Asked by At

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.

1

There are 1 best solutions below

0
On

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');
  }
?>