3

My site allows any user to register but I can verify who they are and then assign a role if I am satisfied.

Can anyone tell me how I can list the content type(s) a user with a particular role is allowed to create? Is this accomplishable via Views?

I also need to detect if they are allowed to create content and display a message to them if they are not.

Thanks.

1

Like @googletorp said, you can't do this with Views, 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');
  }
?>
| improve this answer | |
0

This is not really something you can do with views. If you go to node/add you get the list of content types you can create. You could look in the code and copy/paste it to create a list of content types a user can create or simply link to that page instead.

| improve this answer | |
  • Thanks but my client is insisting on having a dropdown list of node types an authenticated user can create – sisko Jul 21 '11 at 13:07
  • @sisko Best way of doing that is to either explain to the client why it is a bad idea (decreased usability) or to create the form and get the options like explained in a custom module. – googletorp Jul 21 '11 at 13:22

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.