3

When I log in as a user who doesn't have access to certain content types, I can still see a list of those content types in admin/content under the "Show only items where" search. Also, some of the content types don't have any nodes using those content types, yet they are still listed in the dropdown menu under "type".

Rather than confusing certain users, I would prefer only for the content types they have access to, to be listed here. Is this possible?

1 Answer 1

0

Yes. You can alter the form's select box with a hook_form_alter() invocation. All that's needed is to remove the options that aren't relevant to the user.

For example, if you wanted to remove content types where the user didn't have the Edit any TYPE content or Edit all TYPE content permissions, you could do the following:

function token_form_node_admin_content_alter(&$form, $form_state, $form_id) {
  global $user;
  $types = &$form['filter']['filters']['status']['filters']['type']['#options'];
  foreach($types as $type => $type_name) {
    if($type != '[any]' && 
       (!user_access("edit any $type content", $user) && 
        !user_access("edit own $type content", $user))) {
      unset($types[$type]);
    }
  }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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