7 views.api.php hook_views_default_views_alter(&$views)
6 docs.php hook_views_default_views_alter(&$views)

Alter default views defined by other modules.

This hook is called right before all default views are cached to the database. It takes a keyed array of views by reference.

Example usage to add a field to a view:

  $handler =& $view->display['DISPLAY_ID']->handler;
  // Add the user name field to the view.
  $handler->display->display_options['fields']['name']['id'] = 'name';
  $handler->display->display_options['fields']['name']['table'] = 'users';
  $handler->display->display_options['fields']['name']['field'] = 'name';
  $handler->display->display_options['fields']['name']['label'] = 'Author';
  $handler->display->display_options['fields']['name']['link_to_user'] = 1;

Related topics


./views.api.php, line 849
Describe hooks provided by the Views module.


function hook_views_default_views_alter(&$views) {
  if (isset($views ['taxonomy_term'])) {
    $views ['taxonomy_term']->display['default']->display_options['title'] = 'Categories';


This hook DOES NOT need to be in MODULENAME.views_default.inc as hook_views_default_views().

Another example:

function mymodule_views_default_views_alter(&$views) {
$handler =& $views['myview']->display['default']->handler;
// now modify view

After Clear the cache .Revert the views :P

Yes, reverting is a necessary step. However is there a way to do it in code? I really do not want to revert manually.

You can put this code in a hook_update when you need to revert all views or build your own drush command :

* Force revert views.
function HOOK_update_7001() {
  module_load_include('module', 'views');
  $views = views_get_all_views();

  return t('All views has been reverted.');

If you know which views you have to revert, you can call
drush views-revert <view-name-1> <...> <view-name-n>

I have previously implemented the hooks_views_data and hooks_views_data_alter for the views that I created. I need to alter default views, but since the code under hooks_views_default_view is machine generated, I am not sure where to describe the new column and the new handler for the new column.
The following is my hooks_views_data_alter code, it would be great if someone could use this as reference and tell how this can be implemented for hook_views_default_views_alter

function bucket_views_data_alter(&$data) {
$data['example_custom']['actions'] = array(
'title' => t('Bucket'),
'help' => t('Clickable links to actions a user may perform on a row.'),
'field' => array(
'handler' => 'bucket_views_handler_field_actions',
'group' => 'example_custom',
'click sortable' => FALSE,

Note: I am not using drupal's handler, I have written a new handler that I would like to use with hook_views_default_views_alter.

Hope the questions is clear.