I have used custom div for share icon.When admin login to the site the share icon will be shown.and other user login to the site the share icon will be hidden.how can I do this?

2 Answers 2


You can use SharePoint Security Trimmed Control as mentioned at Hide SharePoint 2013 Ribbon based on Permissions

Also, you can use a SPServices to hide DIV with its ID if the current user belongs to a specific group as the following:


<script type="text/javascript">
$(document).ready(function() {
 operation: "GetGroupCollectionFromUser",
 userLoginName: $().SPServices.SPGetCurrentUser(),
 async: false,
 completefunc: function(xData, Status) {
 //If the current User does belong to the group "SharePoint Group Name"
 if($(xData.responseXML).find("Group[Name='Qassas Group']").length != 1)
 // where circle1 is the id of div 
 document.getElementById('circle1').style.display = "none";
 } else
 document.getElementById('circle1').style.display = "block";

For more details, Please check Show / Hide a Div based on a user group in SharePoint via SPServices

Also, you can use SharePoint Security Control

  • I don't know why it not working on my Page. Could You show Divs ?
    – Grzegorz Z
    Commented Mar 24, 2017 at 14:45
  • 1
    make sure that the div has id and put it here document.getElementById('divID').style.display = "none"; Commented Mar 24, 2017 at 14:48
  • Yes my Div has got id="sdiv", and I puted document.getElementById('sdiv').style.display = "none";
    – Grzegorz Z
    Commented Mar 24, 2017 at 14:57
  • 1
    are you replaced your group name at if (xml.search('GroupName') == -1) Commented Mar 24, 2017 at 15:05
  • 1
    Let us continue this discussion in chat. Commented Mar 24, 2017 at 15:09

The proper solution will depend on where you put the DIV tag (e.g. Masterpage (HTML vs. .NET), Page Content, Content Editor Web Part).

You should look into the SPSecurityTrimmedControl. Here are some links that will help you:

SPSecurityTrimmedControl class

How to: Add a Security Trim snippet in SharePoint 2013

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.