I'm creating a "My posts" page users can view on their user page. I only want them to see their own posts, but admins should see them too.

Using contextual arguments Null and User: Uid will match paths like "user/2" correctly, but I can't find a way to restrict the results to admins OR the user with that UID.

If I use a "User: currently logged in" filter it will block out admins too. I wanted to or that with another filter to check for admin permissions but I can't find one.

Probably my brain just isn't working.


boban_dj’s picture

If you make a view of the users post page, then you can manage the permissions or roles for that view.
it is possible to assign permission to user and admin for viewing content.


J V’s picture

That doesn't help since there isn't a permission that applies to this problem

mmitchell816’s picture

Following the notes and suggested answer at: http://drupal.stackexchange.com/questions/30667/how-can-i-exclude-adminu... I was able to achieve the solution you were also looking for.

  1. I edited the contextual filter
  2. Under "WHEN THE FILTER VALUE IS IN THE URL OR A DEFAULT IS PROVIDED" checked "Specify validation criteria"
  3. Then selected "PHP Code" as teh Validator type.
  4. Then entered:
    global $user;
    return ($user->uid == 1 || $user->uid == $argument);

Now if a user goes to a user/(Not their ID)/(views page) they get access denied. But if they go to their own page or an admin goes to the page it works.