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 - SharePoint Expert with Two decades of SharePoint Experience. Love to Share my knowledge and experience with the SharePoint community, through real-time 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.