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 "https://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("https://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();
                }
            }
        }
    }
}

Salaudeen Rajack

Salaudeen Rajack - Information Technology Expert with Two-decades of hands-on experience, specializing in SharePoint, PowerShell, Microsoft 365, and related products. He has held various positions including SharePoint Architect, Administrator, Developer and consultant, has helped many organizations to implement and optimize SharePoint solutions. Known for his deep technical expertise, He's passionate about sharing the knowledge and insights to help others, through the real-world articles!

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

  • 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
  • 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
  • Hi Salaudeen,

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

    Reply
  • 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
    • It can be in feature receiver code, list/site provisioning code, etc.

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *