File C:\wamp\www\sites\all\modules\custom_user\custom_user.info:

name = Custom User
description = Custom User
core = 7.x
dependencies[] = alter_ego

File C:\wamp\www\sites\all\modules\custom_user\custom_user.module:


function custom_user_views_api() {
  return array(
    'api' => 3,

 * Implement hook_user_view().
function custom_user_user_view($account, $view_mode, $langcode) {
  dsm( $account );

File C:\wamp\www\sites\all\modules\custom_user\custom_user.views_default.inc :


function custom_user_views_default_views() {

    $view = new view;
    $view->name = 'custom_user_views';
    $views[$view->name] = $view;
    dsm( $views );
    return $views;


If I add a syntax error within the "custom_user.views_default.inc" function, clearing all caches will return an error. So the function is parsed. But when I reload my page:


I can only see the dsm() from Called from: C:\wamp\www\sites\all\modules\custom_user\custom_user.module, line 15

I'm quite new to drupal. What am I doing wrong ?


1 Answer 1


From https://api.drupal.org/api/views/views.api.php/function/hook_views_default_views/7 ...

This hook should be placed in MODULENAME.views_default.inc and it will be auto-loaded. MODULENAME.views_default.inc must be in the directory specified by the 'path' key returned by MODULENAME_views_api(), or the same directory as the .module file, if 'path' is unspecified.

The files[] element of module .info files can be a little confusing because, as you identified, they do get parsed. However, you will either need to rename your file according to the directions above (custom_user.views_default.inc) and implement hook_views_api() or manually use module_load_include() at another point in your module in order to include extra files.

So, when do you use files[]?

One of the most common uses of the files[] line in your .info file is to take advantage Drupal's Autoloading feature (which is built on top of PHP5's autoloading) for classes. Classes defined in a file like that will have that file load automatically when you need to use that class, thanks to Drupal's auto-loading implementation. The views module stuff makes this a little confusing because it adds another separate auto-loading concept on top of this functionality.

  • renamed to "custom_user.views_default.inc" and removed the file[]. Still not working. I also tried to uninstall reinstall. an I removed every single non necessary modules. Still not called... I did really beleive it though. I would upvote but I do not have 15 reputation. Commented Aug 12, 2014 at 22:17
  • devel/cache/clear?destination=admin/structure After clearing your cache do you still not see the dsm? It works for me. Note that hook_views_default_views() is called very rarely after the initial time. Views relies extensively on caching just about everything it does, because almost everything it does can be extremely expensive. Commented Aug 12, 2014 at 22:39
  • Thanks it worked ! Hopefully i'll come back with upvoting rights one day ;) Commented Aug 13, 2014 at 6:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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