I have a custom list created in SharePoint 2007 and displayed by a Content Query Web Part.

I would like to:

  1. Show all items to general admin users except those items created by two users.
  2. The two admin users need to see all items in the list.

The first requirement is easily done by adding a filter to the view on the Created By field.

The second one is where I need help - is there a way to set the view of a list based on the user logged in?

Or is this achievable another way?


I know I could add another page with another Content Query Web Part without a 'filtered' view and display this link based on audiences to a user group containing two admin users.

I was hoping for a better way without having to create a separate page...

3 Answers 3


What about adding two content query web parts to the same page and displaying them to the respective groups using Audience Targeting?

  • thanks this would have worked for my question, though in the end because of some extra logic for the two cases i went for separate pages...
    – nav
    Commented Sep 17, 2010 at 9:30

You could develop an EventReceiver that sets List Item Level Permissions on items created by these "special" users, so that only they can see those items. No need to fiddle with Views.

  • for my case these users are likely to change in the near future so i would rather use a UI based approach which a SP admin can update the latest user.
    – nav
    Commented Sep 17, 2010 at 9:31
  • You could define a security group and if the user is in that group than assign permissions to that group. New users need to be added to that group then Commented Sep 17, 2010 at 12:17

You could look at Marc's demo page on Query Strings:


This allows your web part to be dynamic based off of the QueryString coming into the page. This however offers no kind of security whatsoever. Security through obscurity isn't security at all. You could also follow a post of mine that deals with List Views and how to security trim each view according to your permission rule set. This would adhere to SharePoint's security model and allow you a bit more control over who can view the data.

Security Trimmed List Views

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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