I'm trying to create a custom views access plugin, so I can perform my conditions for accessing a view.
I read several tutorials and checked the source of existing modules, but I must be coding/doing something wrong because this never works properly.
Here's the code:
File: sample.module
:
function sample_views_api() {
return array(
'api' => 3,
);
}
File: sample.views.inc
:
function sample_views_plugins() {
$plugins = array(
'access' => array(
'test' => array(
'title' => t('Custom access check'),
'help' => t('This is a custom access plugin.'),
'handler' => 'sample_access_plugin',
),
),
);
return $plugins;
}
class sample_access_plugin extends views_plugin_access {
function summary_title() {
return t('Custom acces plugin');
}
function access($account) {
return sample_access($account);
}
function get_access_callback() {
return array('sample_access', array());
}
}
function sample_access($account = NULL) {
return TRUE;
}
I can see the access plugin in views, and I can select it. However, no matter what I do, the access to the view will always be forbidden (access denied). There are no messages in the error log.
Any ideas what's wrong here?
Thanks!