How to hide User Name from SharePoint Lists

Sometimes we need to hide the Created By, Modified By user names in display pages of SharePoint. This requirement mostly come in Surveys where you do not want to show who answered the survey.

You can hide this information from being displayed by setting ShowUser property of SPList object to false.

Following is a code example of doing it:

using (SPSite s = new SPSite("Your Site URL"))
using (SPWeb w = s.OpenWeb("Your Web URL"))
SPList lib = w.Lists["Name of Your Target SharePoint List"];
lib.ShowUser = false;

After running the above code, if you check the properties of an item in your list e.g. document library, you will get the page similar to following

Share via
Copy link
Powered by Social Snap