2

I have my custom master page developed in SharePoint 2013, Now I have a requirement to have some links to be visible for only particular user/group (not on permission so SecurityTrimmedControl will not work for me).

So I have came up with thought to have Content Editor Webpart and put Target Audience in that webpart properties. But when I tried to add this webpart from the Snippet Gallery in masterpage, it has no Target Audience Property.

Can anyone tell me the other possible way except JavaScript/Server side code to check the logged in user permission and then show the link?

  • 1
    You can use Top Navigation/Left Navigation where you can set target audience for particular link. Is this is not an option for you? – P S Jul 5 '17 at 8:58
  • Sorry but that's not an option for me. :) Just wanted to know if any other alternative is there except coding. Thanks btw. – Pradip R. Jul 5 '17 at 8:59
1

You can use the Sharepoint:SPSecurityTrimmedControl to show/hide based on the permission.

Assuming that you need to show links to user who have edit permission, you can add the below snippet in the master page. Here in the permission string, i have set the value as EditListItems:

<Sharepoint:SPSecurityTrimmedControl ID="SPSecurityTrimmedControl2" runat="server" PermissionsString="EditListItems">
    <div id="secretContent">
    ...html
    </div>
    <script type="text/javascript" src="/path-to/custom.js"></script>
 </Sharepoint:SPSecurityTrimmedControl>

Reference - Sharepoint:SPSecurityTrimmedControl

For values in PermissionsString - SPBasePermissions enumeration

This will render the above html content only to users who have the necessary permission.

  • Thank you for the your answer but this works on permission, I already tried this and I wanted to do it based on the group not on permission. Appreciate your answer though. – Pradip R. Jul 5 '17 at 8:18

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.