I have two content types: CTA and CTB. If a user from group A visits the page, I would like to hide CTB. If a user from group B visits the page, I would like to hide CTA. What is the best way to do this?

My way of doing it would probably involve a codebehind on the page, then in the codebehind I would do something like this (pseudocode):

SPWeb w = SPContext.Current.Web;
SPDocumentLibrary dl = GetLibraryByName(name);
dl.ContentType.Hidden = true;
  • 1
    Can you give a little more of the use case? I would say just isolate the content types into their own lists/libraries and restrict access to those areas but your requirements might be different. – Eric Alexander Oct 11 '11 at 17:43
  • @PirateEric By design, both content types have to be in the same document library. To elaborate, group A should only be able to produce content of type A and group B should only be able to produce content of type B. Both groups should be able to see all content. Hence having the same document library. The same document library is also required because I have event receivers that handle parsing uploaded content. This whole thing is well thought out, this question is the last remaining piece. Changing to a multi-document library solution will mean starting over. – KyleM Oct 11 '11 at 17:47
  • I'll bow out, the only way I'd know how to do it is through obscurity which is probably not what you want. – Eric Alexander Oct 11 '11 at 18:05

You could set the content type to hidden across the board, and then create a custom UI, either by modifying the ribbon or via some other web part to create the actual content. In this scenario, there would be no way for a user to create items of that content type other than using your UI. You could have logic in that customization to check the users rights.

| improve this answer | |
  • This is a good suggestion, but I would rather keep the document library solution I'm currently using since everything else is set up for that (event receivers, content types, columns). – KyleM Oct 12 '11 at 13:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.