SharePoint: Hide a web part for selected users


"Out of the box" there are no "deny permission" features in SharePoint, only grant permissions. If you have a group called Sales with 1000 users, and you would like to use the SharePoint Audience feature to display a web part for everyone in Sales except for Sam, Susan and Bob, you will have to create a new group with 997 users named "Sales except for Sam, Susan and Bob" (and then maintain two groups going forward. But there is a way…

Here's a trick that starts by using a Content Editor Web Part to hide another web part from everyone. By creating a group with our three problem people and using that as an Audience for this CEWP we can selectively hide another web part. 

Before we start, Audiences are not available in WSS 3.0 (2007) or SharePoint 2010 Foundation.

For this trick you need to do four things:

  • Create the group or audience of people to hide things from
  • Discover the ID of the web part you want to hide (see here for 2007 and 2010)
  • Write a bit of CSS to hide the web part
  • Add a Content Editor Web Part to hold or link to the CSS and audience filter it


Create the audience:

Your audience can be any AD group (Distribution/Security Group), any SharePoint group you create or a custom audience (Global Audiences) created by your server administrator. For testing proposes you make want to create a test SharePoint group named "TheNoSeeGroup".

The CSS:

The CSS is quite simple, just a "display:none" to hide the entire web part. As this will placed in a Content Editor Web Part that will only be seen by the "TheNoSeeGroup" this CSS will only be effective for those users. The trick here is to get the ID of the web part you want to hide.


Discovering the ID of the web part to hide:

Go to the page with the web part to hide (such as Shared Documents) and use your browser's View Source option to see the page's HTML. Do a search for MSOZoneCell_WebPart and browse around to see if there's any hints that your found the right web part. If not, search again. For more help, go her for 2007 and here 2010. The ID will look something like MSOZoneCell_WebPart9. Note that if you delete and re-add the web part it may receive a new number.



  1. Find your web part's ID  (MSOZoneCell_WebPart1, MSOZoneCell_WebPart2, etc)
  2. Open Notepad and add the CSS from above using your web part's ID
  3. Save the Notepad file and upload to a SharePoint library in your site (I used Site Assets and named the file HideWebPart.htm)
  4. Go to the library where you loaded the file, right-click the file and select Copy Shortcut (or better, right-click the file, click Properties and copy the URL from there)
  5. Go to the page with the web part you want to hide, edit the page and add a Content Editor Web Part (CEWP) above the web part you want to hide
  6. Edit the CEWP and paste the URL copied earlier for the CSS Notepad file
  7. Click OK… The Shared Documents web part should now be hidden (from everyone!)
  8. Edit the Content Editor Web Part again
  9. In the web part's properties panel expand the Advanced section, scroll to the bottom and select the audience to hide the web part from
    Note that in 2010 the text box has no visible border!
  10. Save your changes and test by have a group member, and a non-group member, log in and see if the web part is displayed.

Note for 2010: If you can't see the CEWP when you edit the page (to edit it or to delete it) it's because you are not in the right group! Either add yourself to the "hide from" group or use a trick from here to display a list of all of the web parts, append ?Contents=1 or &Contents=1 to the end of the page's URL.



Anonymous said...

A deny-access security group is exactly the kind of negativity in the workplace we want to avoid. Imagine checking your group membership & seeing “DenyAccess_BestWebPartEVER”, how demotivating is that? What is this webpart? why don’t I get to see it? You can see how that impacts productivity… I’d much rather add 97 individual members to a security group than crush the dreams of those poor 3 who just found out they don’t get to see the best web part ever. Maybe the real issue is that those 3 people who you don’t want to see the webpart shouldn’t be working there in the first place.

John Minihan said...

Gee Anonymous (and why anonymous?), if you don' like it don't use it. But don't knock it! I know people who have spent weeks trying to implement this. Example: Application Portlet on a page but not all users are licensed for the application. So we want to show them a pretty picture rather than the ugly Access denied.

Mike - I just love this solution. Well done and thanks.

Anonymous said...

This solution really helps me, I am woking with sharepoint online (office 365), and it doesn't allow anonymous users.

With this solution I just hide some webparts for "all autheticated users". So I dont need anonymous users in audiences ... thanks.

Anonymous said...

Dont find the target audience in my webpart properties whats the reason for that

Anonymous said...

Dont find the target audience in my webpart properties whats the reason for that

Mike Smith said...


Three possibilities...

The Target Audience is not available in SharePoint Foundation.

It might be a custom or third party web part that does not support audiences. (And there might be some SP web parts that don't.)

The text box is there, but in SP 2010 it does not have a border and is "invisible". Click the browse button next to it.


Anonymous said...

Thank you!! This worked very well for me.

Anonymous said...

Is it possible to hide a CEWP webpart from anonymous users?

Mike Smith said...

> Is it possible to hide a CEWP webpart from anonymous users

Yes, use an Audience on the CEWP. Pick one that applies to all of your logged in users.


Anonymous said...

Mike - thank you SO much for posting this! I've been wanting to do something like this for a long time. I just found this post and your solution works perfectly!

Anonymous said...


I just implemented this in a SharePoint Online site and it works like a charm.
I decided to insert individual account instead of a group and wanted to go back to the Content Editor Web Part, but it is not there anymore (above the web part I want to hide).

So my question: once you have implemented it, and want to make additonal changes, where can I find it ?


Mike Smith said...

> So my question: once you have implemented it, and want to make additonal changes, where can I find it ?

Go to the library where you stored the Notepad file with the JavaScript code. Either rename it, delete it, or edit the file and change the line with "display:none;" to "display:inline;".


Note to spammers!

Spammers, don't waste your time... all posts are moderated. If your comment includes unrelated links, is advertising, or just pure spam, it will never be seen.