The answer will depend on what your created menu items route to (hook_menu()
is for defining new menus so it won't help you here).
Generically, hook_menu_alter()
allows you to alter the access callback
so that you can override access with your own logic. If the path you're overriding is specific to a special module route (e.g. admin/dashboard), then it would make sense to use this hook.
/**
* Implements hook_menu_alter().
*/
function MYMODULE_menu_alter(&$items) {
$items['admin/dashboard']['access callback'] = 'MYMODULE_access';
}
/**
* Access callback function
*/
function MYMODULE_access() {
global $user;
$user_entity = user_load($user->uid);
// @TODO: Check your user entity's taxonomy field for access and return
// TRUE | FALSE
// EXAMPLE: Allow access for USER #123
// return ($user_entity->uid == 123);
}
If your created menu items link to content nodes then you should look at hook_node_access()
. This hook is specifically designed for controlling access to nodes so you'll have access to the node/user object from the hook's arguments.
/**
* Implements hook_node_access().
*/
function MYMODULE_node_access($node, $op, $account) {
$user_entity = user_load($account->uid);
// @TODO: Check your user entity's taxonomy field for access and return
// NODE_ACCESS_ALLOW | NODE_ACCESS_DENY | NODE_ACCESS_IGNORE
// depending on your logic
}