2

I'm trying to implement some custom access control for user entities, in Drupal 7.

I've used hook_entity_info_alter to set

$entity_info['user']['access callback'] = 'MYMODULE_user_access_callback';

and when I call entity_get_info at a later point, I can see that this is still successfully set.

But MYMODULE_user_access_callback never ever seems to get called when I try to display users directly, or load Views of users.

It looks like the custom access callbacks are normally called from the entity_access function in entity.module. But the user_access function in user.module doesn't ever call them.

user_load in the user module calls entity_load, which calls entity_get_controller($entity_type)->load(...)

but this still doesn't seem to invoke entity_access.

So is setting 'access callback' for the user entity a wrong way to go about trying to implement custom user access control? Do I need to override UserController perhaps?

0

The problem might be the execution order of the modules

How to change access callback of user entity when entity module is installed? (how to make sure my alteration is the last)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.