Monday, February 8, 2016

Hiding a Site Content Link from Setting Icon in SharePoint 2013

Hello Everyone,

Recently I received a  requirement from client to hide Site Content Links from only one site page which 

comes along with Setting Wheels from Corner. I have tried a lot to achieve it from OOTB  but I did't get any solution,I have gone through many blogs and articles they are suggesting to make a changes in Master Page which does not make sense to do the changes for only one Page. so I have decided to use JQuery and REST to achieve my requirement. I hope this will help you a lot .

Please use below code to hide the site content Link

//get the current LoggedIn User Id

var userID=_spPageContextInfo.userId;

//Function to check If User Is Site Admin then then Site Content Link should be visible as it is if not then hide.

function CheckUserIsAdmin() {
$.ajax
({
url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/GetUserById(" + userID + ")",
type: "GET",
headers: {
"accept": "application/json;odata=verbose",
},
dataType: "json",
async: true,
success: function (data) {

//if loggedIn user is not a site Admin then hide the site content
var Obj=data.d.IsSiteAdmin;
var element;
if(!Obj)
{
var element=$("#siteactiontd").children().children().children()[4];
element.remove();
}
}
});
}

</script>

Thanks,

Pankaj Srivastava


by Pankaj Srivastava via Everyone's Blog Posts - SharePoint Community

No comments:

Post a Comment