I am a newbie in drupal, i have created a new content type 'new', I have two type of roles Editor and manager. Editor must be able to add content in to the new开发者_开发百科 content type but manager wont. I have specified in the module code that
function new_access($op, $node, $account) {
switch ($op) {
case 'create':
return user_access('create NEW', $account);
}
}
Now the editor got the permission for this and he can add content, but when manage login when also view the new content type but clciking on the menu will show 'Access Denied'
I want to make this content type in such a way that, when manage logins the content type 'New' must not be in the create content link
please help
Thank you
If you've created the new content type through the Drupal interface and not through a custom module (that is, you went to Content management -> Content types and added it there), it's much easier to restrict this.
Simply go to User management -> Permissions, look under the node heading, and uncheck Create NEW content under the Editor role.
If you have created the content type through the use of a custom module, you'd still go to the Permissions page, but in your custom module, you need to implement hook_perm()
in addition to hook_access()
:
function new_perm() {
return array('create NEW');
}
Then you can use user_access('create NEW', $account);
to check against the create NEW
permission.
精彩评论