I have a really strange issue occurring within a view I've created. I have the same code base on two servers, one is a stage server one is on a Vagrant instance on my local machine.

The view displays messages for a user (the UID is retrieved from the currently logged in user via a contextual filter). If I pass the UID of a user I know has messages into the contextual filter preview box in the Views admin panel while logged in as root then the view returns a record. If I try the same with another user it does not even though I am specifying the same UID, and the other user has the "administration" role checked in their profile so they should have the same permissions.

Does anybody have any ideas as to what may be causing this? I have a feeling it's something to do with configuration as like I said, the code base is mirrored yet works on one site but not the other.

  • "administration" role does not guarantee all the same permission. UID1 always has all permissions and you can't take them from him, but for a custom role it is possible you have simply not clicked a checkbox or two on permissions page.
    – Mołot
    Sep 4 '13 at 14:26
  • 1
    Molot - I know UID1 has all permissions, I made sure to ensure that every permission was enabled for the admin user. Sep 4 '13 at 14:46
  • How are you setting the contextual filter in view? Are you using "user: uid" and getting the value from currently logged in user? In past addding a contextual filter on user: uid and setting if no filter value is there build a default value using the logged in user which will give you one user object of currently logged in user.
    – pgrujic
    Sep 4 '13 at 15:03
  • pgrujic - It's currently set to get the UID from the currently logged in user. I've also tried manually setting the UID via the preview field in the views admin panel and passing the UID via calling views_embed_view. Nothing seems to work unless I'm logged in as root. Sep 4 '13 at 15:39

Views hardcodes RIDs in when you export or featurize a view. That means that if the role has a different RID on one site than on the other, you'll have issues with Views giving permissions to the wrong users.

One way I've gotten around this is to hack the exported view, and where it would say something like

$handler->display->display_options['access']['role'] = array(
  4 => 4,

I have

$rid = ($role = user_role_load_by_name('administrator'));
$handler->display->display_options['access']['role'] = array(
  $rid => $rid,
  • You had my hopes up for a minute, unfortunately I don't have any access stuff set in the view, it should be open for all authenticated users (the view block is added via context which checks the roles, but as I said I'm testing this from within the views admin panel). Sep 5 '13 at 8:48

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.