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?

2
  • 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
    Commented Jul 5, 2017 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.
    Commented Jul 5, 2017 at 8:59

2 Answers 2

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.

1
  • 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.
    Commented Jul 5, 2017 at 8:18
0

There is a tricky solution: You can add a webpart to a page normally, in a webpart zone. In this webpart you can specify the css style to display or hide any element you want. Finally set target audience to this webpart and everything will work as expected.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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