SharePoint: Customize default NewForm.aspx and hide some fields according to given permissions
<p>My requirement is to restrict users to view/add/edit fields of a list as per their given group/permission. To achieve this objective as per my understanding I have to generate custom list forms. If anyone can help me to customize NewFrom.Aspx and code in such a way that we can check current user group/permission and hide fields which should not be accessible to him.</p>

<p>I have derived solution after googling and have thought to apply below thing after creating new custom list form. I want to know if this approach is good enough or give any optimal solution to it.</p>

<pre><code>        var web = SPContext.Current.Web;
        web.AllowUnsafeUpdates = true;
        web.Update();
        var lists = web.Lists["SomeList"];
        var f = lists.Fields["SomeField"];
        if(){ //to check if user is in role
        f.ShowInEditForm = false;
        f.ShowInNewForm = false;
        f.Update();
        }
</code></pre>

<p>The same list will be used ac cross all the users so I think above solution might not be optimal.</p>

<p>Thanks in advance.</p>