I made a custom view mode with display suite for the user entity. It is called "user_teaser" and shows some fields that may be visible for Anonomous user. Unfortunately currently anonymous users cannot see it because of the general "View user profiles" permission which they have no access to.
Which hook should I use to bypass this permission and allow anonymous to see my custom view mode?
I tried hook_entity_view_alter() as below, but this is called already too late I think as it is not even called when the access to the user profile is blocked.
function MODULE_entity_view_alter(&$build, $type) {
if ($build['#view_mode'] == 'user_teaser') {
$build['#access'] = TRUE;
$build['user_image']['#access'] = TRUE;
}
}
So I would need a hook_entity_access_alter or hook_user_access_alter or a hook_entity_access_query_alter, but they don't exist.
(edit) I found now some lead that might have a solution: How to change access callback of user entity when entity module is installed? (how to make sure my alteration is the last)