Drupal 7 Access Callback Not Working Properly -


drupal 7 hook_menu access callback not returning correct boolean.

before begin. yes! cache cleared... lot.

i implemented simple function testing:

$items['tutor_review_selection'] = array(     'title'             => t('example'),     'page callback'     => 'my_module_example_page',     'access callback'   => my_module_access( array('administrator') ),     'type'              => menu_normal_item );  function my_module_access( $roles ) {     global $user;      $check = array_intersect($roles, array_values($user->roles));      return empty( $check ) ? false : true; } 

this returns true logged in , logged out users.

here important part:

i call 'my_module_access' function in 'my_module_example_page' function , works correctly.

can shine light onto why not work in access callback?

maybe order of operation?

cache cleared.

if check drupal 7 hook_menu documentation see following code:

  function mymodule_menu() {     $items['abc/def'] = array(       'page callback' => 'mymodule_abc_view',       'page arguments' => array(1, 'foo'),     );     return $items;   } 

'page callback' accepts string, callback function name. arguments sent function provided in 'page arguments' array.

edit note should create permission , assign roles permission, check permission instead of checking specific roles.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

jquery - Keeping Kendo Datepicker in min/max range -

jsf - How to ajax update an item in the footer of a PrimeFaces dataTable? -