1

I'm creating a view to list user sessions statistics. (Data selected from table myuserstat, there is UID field, myuserstat rows is not a Content Type, just table)

I want to make access url like /mystat/{user}, to list data of specified user.

How can I allow users to see their own stat, and admins see all users stat? For now i only found how to limit to the current user: contextual filter->UID->Provide default value->logged user id. But in that case, how to allow admins to view all users?

1 Answer 1

1

Create another view or a page within same view with path /mystat or path can be different without using contextual filters. And in page seetting option in view choose access from none to role and select admin role.

3
  • Yes, thats straightforward way, but i thought there is more right/drupal way.
    – Vovka
    Dec 14, 2016 at 7:55
  • another way of doing this is by using hook_view_query_alter where you can remove contextual filters in case of uid = 1; Dec 14, 2016 at 7:59
  • @Vovka you're over thinking this. This is exactly how you should do it. Ever heard of KISS? Not the rock band.
    – No Sssweat
    Dec 14, 2016 at 9:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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