access to custom admin menu item by role in Drupal 7

2.1k views Asked by At

I added a custom admin menu item which I'd like to show up for non-admin users with specific roles. Is there a way to accomplish this?

Thanks in advance! Lee

1

There are 1 answers

2
prabeen giri On

Create custom access callback in your custom hook_menu:

//custom hook_menu() 
$items['menu'] = array(
  ................. 
  'access callback' => 'my_custom_callback' 
); 

function my_custom_callback() { 
 global $user; 
 if (in_array('[YOUR_ROLE]', array_values($user->roles))) {
    return TRUE; 
  }
}