Hi
I've defined a view with a contextual filter wich is $account->uid. Now I want to limit the access to this view just to main administrator and "own" users. By "own" I mean, for example, that user 23 is only allowed to access his own view wich is my_view/23.
I'm trying to achieve this using PHP access with no success. Available variables in PHP access are:
$view_name: The name of the view to check.
$display_id: The ID of the display to check.
$account: The account to check.
The basic approach should be to retrieve the global drupal $user variable wich is the current logged in user and comparing it with the current argument of the view but it doesn't seem to work. It simply allows everybody to access everybody's view (I'm pretty sure that $account == $user):
global $user;
if ( ($user->uid == 1) or ($user->uid == $account->uid) ) {
return TRUE;
}
My second option was to retrieve the current view, get its argument and compare it against the $account/$user variable:
$view = views_get_current_view();
if ( ($account->uid == 1) or ($account->uid == $view->args[0]) ) {
return TRUE;
}
...and no luck for the generic users, ($account->uid == $view->args[0]) ) doesn't seem to work. And, at this point, I don't really know how to continue. Any idea or suggestion about this issue?
Thanks in advance.
Comments
Comment #1
NoRandom commentedMy fault, this issue is related with Views PHP, not Views.