I have create module for uploading files into database, and only administrator can upload that files. So I have hook_permission
for administer to upload files:
function upload_permission() {
return array(
'administer uploader' => array(
'title' => t('Administer Uploader'),
'description' => t('Allow the following roles to upload files files to the server.'),
),
);
}
Also I create several custom nodes with path files/node/%
and now I need permission for anonymous users to see page with custom nodes. Below I add this permission:
'access files/node/%' => array(
'title' => t('Access Files'),
'description' => t('Access Files.'),
),
and still don't work. Is there any other solution how anonymous user can view the page with custom nodes ?
As far I know, just check the permission "view published content" in the CMS permission page that should be checked for the anonymous user role. For viewing a Drupal node no specific permission needed until you are using any individual node permission settings. Also, for your custom node path please use the below settings array in your hook_menu to make all path works with the URL 'files/node/%'.
/**
* Implements hook_menu().
*/
function yourmodule_menu() {
$items = array();
$items['files/node/%'] = array(
'title' => 'Files node',
'page callback' => '_yourmodule_page_callback',
'page arguments' => array(2),
'access arguments' => array('access content'),
'type' => MENU_CALLBACK,
);
return $items;
}
Just notice the below line of code, this say that anyone with the permission 'access content' (View published content) can see these node.
'access arguments' => array('access content'),
Hope this will help you!