How to change access callback of user entity when entity module is installed? (how to make sure my alteration is the last) I want to change the 'access callback' of user entity to my own access function or at least alter the original function 'entity_metadata_user_access'.

The problem is that 'entity module' which I need because of others' module dependencies already alters the 'user entity information' and changes the 'access callback' to its own function 'entity_metadata_user_access' and so when I alter it with my module, the entity module re-alters it to 'entity_metadata_user_access'.

To make it more clear, the entity module is alters the entity info after me which causes that the final value of the callback is not mine (does not come from my alteration) but its and therefore the callback is wrong.

I know that I could modify the module itself but I honestly don't want to do that because it makes later updates painful.
Here is a complete working example of overriding entity_metadata_user_access:

/**
 * Implements hook_module_implements_alter().
 */
function YOURMODULE_module_implements_alter(&amp;$implementations, $hook) {
  if ($hook == 'entity_info_alter') {
    $group = $implementations['YOURMODULE'];
    unset($implementations['YOURMODULE']);
    $implementations['YOURMODULE'] = $group;
  }
}

/**
 * Implements hook_entity_info_alter().
 */
function YOURMODULE_entity_info_alter(&amp;$entity_info) {
  $entity_info['user']['access callback'] = 'YOURMODULE_entity_metadata_user_access';
}

/**
 * Overrides entity_metadata_user_access function.
 */
function YOURMODULE_entity_metadata_user_access($op, $entity = NULL, $account = NULL, $entity_type = NULL) {
  // Include Entity API module's logic
  $return = entity_metadata_user_access($op, $entity, $account, $entity_type);

  // Do your own logic here:
  // $return = $return || ...

  return $return;
}