New hooks to be added in Drupal 7.17
There are two new hooks added in Drupal 7.17 core, which is scheduled to be released on 7 November 2012.
Introduced in Branch: 7.x, 8.x
Introduced in version: 7.17
Drupal 7.17 introduces a new hook, hook_entity_view_mode_alter(), which allows modules to programmatically alter the view mode when an entity is being displayed.
<?php
function mymodule_entity_view_mode_alter(&$view_mode, $context) {
// Change the view mode to teaser for anonymous users viewing a node.
if ($context['entity_type'] == 'node') && user_is_anonymous()) {
$view_mode = 'teaser';
}
}
?>
The hook also exists