Community Documentation

Views Access Callback

Last updated February 8, 2012. Created by maciej.zgadzaj on February 8, 2012.
Log in to edit this page.

Views Access Callback module provides callback-based access control for Views.

Available callback functions are defined by modules using hook_views_access_callbacks() function, then could be set in in view's Access restrictions configuration.

Example hook_views_access_callbacks() implementation:

/**
* Implementation of hook_views_access_callbacks().
*/
function MYMODULE_views_access_callbacks() {
  return array(
    'MYMODULE_user_has_access',
  );
}

Callback function should return either TRUE (if access should be granted) or FALSE (if access should be forbidden).

If view has arguments defined, their values will be passes as callback function parameters.

function MYMODULE_user_has_access($arg1 = NULL, ...) {
  if ( ... ) {
    return TRUE;
  }
  return FALSE
}

Note that users with access all views permission can see any view, regardless of any other permissions.

About this page

Drupal version
Drupal 6.x
Level
Beginner
Audience
Programmers, Site administrators
Drupal’s online documentation is © 2000-2013 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License. Comments on documentation pages are used to improve content and then deleted.