Hide/Show SPRibbon in SP2010 / 2013 based on User Permission by using SharePoint Designer in
1. Just call the Jquery file in master page header section like below.
<script type="text/javascript"
src="/Style%20Library/jquery-1.6.1.min.js"></script>
2. We need to remove the welcome menu control from
< SharePoint:DelegateControl >
3. Add this below DIV controls after SPRibbon DIV tag closed.
<div class="s4-trc-container-menu1" style="text-align:right;float:right;width:100%; position:absolute;margin-top:10px;">
<div id="notificationArea1" class="s4-noti" style="right: 16px;
top: 0px; height: 22px">
<wssuc:Welcome id="IdWelcome1" runat="server"
EnableViewState="false"></wssuc:Welcome>
<wssuc:MUISelector ID="IdMuiSelector1" runat="server"/>
</div>
</div>
4. Then finally Add below script before body tag closed.
<script type="text/javascript">
var UserHasPermissions = false;
</script>
<Sharepoint:SPSecurityTrimmedControl ID="SPSecurityTrimmedControl1" runat="server" PermissionsString="ManageWeb">
<script type="text/javascript">
UserHasPermissions = true;
</script>
</SharePoint:SPSecurityTrimmedControl>
<script type="text/javascript">
if (UserHasPermissions) {
document.getElementById("s4-trc-container-menu1").style.display = "none";
}
else {
document.write('<scr' + 'ipt type="text/javascript" src="/Style
Library/RemoveWelcomeMenuOption.js"></scr' + 'ipt>');
if (getQueryVariable("IsDlg") != "undefined")
if (getQueryVariable("IsDlg") == "1") {
document.getElementById("s4-ribboncont").style.display
= "inline";
}
else {
document.getElementById("s4-ribboncont").style.display
= "none";
document.getElementById("s4-trc-container-menu1").style.display = "block";
}
function getQueryVariable(varname) {
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i = 0; i < vars.length; i++) {
var pair = vars[i].split("=");
if (pair[0] == varname) {
return pair[1];
}
}
}
}
//RemoveWelcomeMenuOption.js
jQuery(document).ready(function($){
$("[text='My
Settings']").remove();
$("[text='Personalize
this Page']").remove();
});
</script>
Comments
Post a Comment