6.x-3.x views_plugin_access.inc views_plugin_access::get_access_callback()
7.x-3.x views_plugin_access.inc views_plugin_access::get_access_callback()

Determine the access callback and arguments.

This information will be embedded in the menu in order to reduce performance hits during menu item access testing, which happens a lot.

Return value

an array; the first item should be the function to call, and the second item should be an array of arguments. The first item may also be TRUE (bool only) which will indicate no access control.)

4 methods override views_plugin_access::get_access_callback()
views_plugin_access_perm::get_access_callback in plugins/views_plugin_access_perm.inc
Determine the access callback and arguments.
views_plugin_access_role::get_access_callback in plugins/views_plugin_access_role.inc
Determine the access callback and arguments.
views_test_plugin_access_test_dynamic::get_access_callback in tests/test_plugins/views_test_plugin_access_test_dynamic.inc
Determine the access callback and arguments.
views_test_plugin_access_test_static::get_access_callback in tests/test_plugins/views_test_plugin_access_test_static.inc
Determine the access callback and arguments.

File

plugins/views_plugin_access.inc, line 88
Definition of views_plugin_access.

Class

views_plugin_access
The base plugin to handle access control.

Code

function get_access_callback() {
  // default to no access control.
  return TRUE;
}

Comments

cmonnow’s picture

Just to clarify, in addition to $this->options (if applicable), $this->view etc you can pass fragments from the view's URL path to your custom access callback function as an integer as usual (integers in the path will be converted while objects and strings are passed through).

For example, if your path is user/%/bookmarks and you want to pass the uid from % as an argument in your callback function, you add 1 to the array like so:

function get_access_callback() {
return array('custom_example_user_view_access_callback', array(1));
}

Collins405’s picture

Can you clarify how this is done? I'm struggling to find the variables available to me from the view.

I have it all set up, but cant figure out what variable I use to get the integer from the %