0

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

You can use a SPServices to hide div with its ID if the current user belong to a specific group as the following

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery.SPServices/2014.02/jquery.SPServices.js"></script>
<script type="text/javascript">
$(document).ready(function() {

 $().SPServices({
 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";
 } 
 }
 });
});
</script>

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

|improve this answer|||||
1

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

|improve this answer|||||

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.