php - Allow only certain roles access to custom module in Drupal -


i having trouble getting working correctly. have created order form module drupal , need control access it. noticed order form accessible without being logged in if browse directly http://example.com/orders/order-form have been looking around , think on right track missing simple. have created function below in order-form module:

function order_form_permission() {   return array(     'order form permission' => array(       'title' => t('order form permissions'),       'description' => t('deny access users.'),     ),   ); } 

then in same file create page use function:

function order_form_menu() {     $items = array();      $items['orders/order-form'] = array(         'title' => 'order form',         'descriptions' => 'a form ordering products',         'page callback' => 'drupal_get_form',         'page arguments' => array('order_form_form'),         'access arguments' => array('order_form_permission')     );     return $items; } 

the page arguments array contains call form generated.

i have set permissions user roles in admin/people/permissions shows access denied when not logged in want. when browse page logged in main administrator can see it, want.

the problem when try log in user or account has role assigned want able access order form access denied. must missing simple here can me out.

actually don't need define access callback, defaults user_access() function powered hook_permissions drupal.

the access arguments in hook menu should same array key in hook permission. try removing underscores

'access arguments' => array('order_form_permission')


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -