I have a list, users can add items to it. By applying current user filter web part, I can show the items created by the login user. However, for some users, i.e. belong to 'admin' group, I want to show all items.

Is it possible to do this? thanks


In that case I would create two web parts on one page: one web part that will be seen only by users who are not a member of the "admin" group, and one that will be seen only by users who are a member of the "admin" group.

Wrap a div around both web parts and give each div a unique ID, for example "customWB1" for the web part that all users should see, and "customWB2" for the users that are a member of the "admin" group.

Using JavaScript and SPServices, you can use the following code to check if the current user is a member of the group "admin":

$(function() {
   var userGroupArray = new Array();
   var group = "admin";

   var userGroup = $().SPServices({ 
      operation: "GetGroupCollectionFromUser", 
      userLoginName: $().SPServices.SPGetCurrentUser(), 
      async: false, 
      completefunc: function(xData, Status) {
         $(xData.responseXML).find("Group").each(function() {

   function include(arr, obj) {
      for (var i = 0; i < arr.length; i++) {
         if (arr[i] == obj) return true;

   if(include(userGroupArray,group)) {
      // user is a member of the "admin" group
      $("#customWB2").css("display", "block");
      $("#customWB1").css("display", "none");
   else {
      // user is not a member of the "admin" group
      $("#customWB1").css("display", "block");
      $("#customWB2").css("display", "none");      

If you put that code in a script editor web part on the same page as those two list web parts, then it should work properly. Don't forget to download the JQuery library and the SPServices library too if you haven't got it already, and add a reference to them. You should add the reference to those libraries at the top of the script editor web part, before your code, like so:

<script type="text/javascript" src="Style Library/Scripts/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="Style Library/Scripts/jquery.SPServices-2013.01.min.js"></script>

Keep in mind that I made a "Scripts" folder in my Style Library, if you store your scripts elsewhere then make sure to change the path in the source of the code in the previous two lines.

I hope this was of any help to you!

Best regards, Magali

| improve this answer | |
  • I did not test this, but it seems will work. Thanks. What we implemented is similar to this. 1) Created 2 Views, one included all results, the other filtered by [Me]; 2) Added 2 webparts to show the results for each view, and then add Audience, so only certain groups can see all results. 3) and then use javascript to hide one of the webpart. – urlreader Apr 28 '14 at 16:20
  1. Create a view for that list
  2. Create a column Person or Group and set Allow selection of:People and Groups and If you want use sharepoint group set Choose from:SharePoint Group
  3. in sharepoint designer open the view that you create and use this code to filter:

enter image description here

In the fieldRef name you must type your column name! Hope this usefull

| improve this answer | |
  • this does not work for my case. this filters result based on group, but for some other groups, i.e. admin, I want to show all results. – urlreader Apr 28 '14 at 16:11
  • So You can create multiple view one of them for admin and another for other group that see filter items! – aMir Kazemi Apr 29 '14 at 6:15

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.