How to Hide User Names in Created by, Modified by Fields in SharePoint?

Requirement:  Had to provide complete anonymous entries in SharePoint task list by masking user names (as in SharePoint Surveys).

Here is the Trick: There is a Property for SharePoint List, called “ShowUser”. we can set that to “False” using PowerShell or C# object model.

PowerShell script to Hide User Names in SharePoint:

$SPweb=Get-SPWeb "http://sharepoint"
$SPlist=$SPweb.Lists["Tasks"]
$SPlist.ShowUser=$false
$SPlist.Update()
sharepoint hide user name

and here is the effect in action:

sharepoint mask user names

Hide User Name in SharePoint 2007:

For MOSS 2007, You can do the same using C# code (PowerShell also possible!)

namespace HideUserInfo
{
    class HideUserInfo
    {
        static void Main(string[] args)
        {

            using (SPSite oSPSite = new SPSite("http://SharePoint.com"))  //Site collection URL
            {
                using (SPWeb oSPWeb = oSPSite.OpenWeb("News"))  //Subsite URL
                {
                    SPList oSPList = oSPWeb.Lists["Pages"];   //List/Library Name
                    oSPList.ShowUser = false;
                    oSPList.Update();
                }
            }
        }
    }
}
mask user info

Salaudeen Rajack

Salaudeen Rajack is a SharePoint Architect with Two decades of SharePoint Experience. He loves sharing his knowledge and experiences with the SharePoint community, through his real-world articles!

5 thoughts on “How to Hide User Names in Created by, Modified by Fields in SharePoint?

  • September 29, 2016 at 5:32 PM

    I added this to discussion board which looked like it worked fine. However I wasn’t able to reply for the topic as it kept on saying “Invalid data has been used to update the list item. The field you are trying to update many be read only”

    Reply
  • November 6, 2014 at 2:34 PM

    Hi,

    have you ever tried to use a filter on the column “modified by” when you see the list? I see the list entries masked but the filter is showing me the clear user names and I can filter down the entries!?

    Cheers
    JK

    Reply
  • October 18, 2012 at 4:55 PM

    Hi Salaudeen,

    How to get a list of all external users based on “modified by” column in SharePOint Site collections?

    Reply
  • October 4, 2012 at 3:43 PM

    Hi salaudeen,

    what do we deploy it as ? Is it as a feature or something else please let me know the options if i use c# to achieve this.

    Reply
    • October 6, 2012 at 1:55 PM

      It can be in feature receiver code, list/site provisioning code, etc.

      Reply

Leave a Reply