SharePoint 2010 ECB Menu

Hello Friends,

I wanted to find how I can hide the whole ECB Menu for all users except admin ?

I believe there is a simple way of doing this using the securitytrimmed control in master page -Any idea on how to do this ?

I also know there is another way of using customcore.js file but i dont know how to hide the whole menu for all users except admins (Who have manageweb-SPUSERBASEPERMISSIONS)  

> What code do i need to modify...an detail explanation to do this would be much appreciated as I am very new to Javascript...I have gone through N number of articles but they speak of hiding 1 item and not the whole menu...please guide 

March 24th, 2015 7:53pm

Use IE developer tools to find the class which represents the ECB menu. I don't have SP 2010 VM right now, but attached is the screen shot of SP 2013:

Now, place content editor web part on the page. Add the JSOM script to determine if current user is site admin and based on the result hide the ECB menu class. 

var context;
var web;
var isAdmin = false;
function CheckUserPermissions() {
    context = new SP.ClientContext.get_current();
    web = context.get_web();
    context.load(web, 'EffectiveBasePermissions');
    context.executeQueryAsync(onSuccess, onFailure);
}
function onSuccess() {
    if (web.get_effectiveBasePermissions().has(SP.PermissionKind.manageWeb)) {
        isAdmin = true;
    }
}
function onFailure(sender, args) {
    alert('request failed ' + args.get_message() + 'n' + args.get_stackTrace());
}

Or use this:

function isCurrentUserSiteAdmin(OnSuccess,OnError)
{
    var context = SP.ClientContext.get_current();
    var list = context.get_web().get_siteUserInfoList();
    var userItem = list.getItemById(_spPageContextInfo.userId);

    context.load(userItem);
    context.executeQueryAsync(
        function() {
          var isSiteAdmin = userItem.get_item('IsSiteAdmin');  
          OnSuccess(isSiteAdmin);           
        },
        OnError
    );


}

Source: http://sharepoint.stackexchange.com/questions/89604/check-an-admin-account-only-using-javascript

Use JQuery to show/hide the ECB menu:

$(".ms-list-itemLink").css("visibility", "visible");

Free Windows Admin Tool Kit Click here and download it now
March 25th, 2015 1:50am

Unfortunately, this wont work for me as I want to disable for all lists and libraries.
March 26th, 2015 7:34pm

You can put the script in master page. It will then run on all pages.
Free Windows Admin Tool Kit Click here and download it now
March 26th, 2015 11:28pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics