I need to be able to hide the ‘Settings’ cog, from everyone other than the site Super Users, on the New & Edit forms of a specific Custom List.

My Javascript skills aren’t great, but a colleague in my company’s IT team has got me very close with the snippet below. It successfully hides the cog on the selected New & Edit forms to anyone other than the site Super Users (referenced in the code by their email addresses), but unfortunately is also hiding the cog from general users on all other pages across the site. I need users to be able to see it on all pages other than the selected New & Edit forms.

As the code only references the New & Edit forms, we can’t understand why it is impacting other pages. Any advice will be very much appreciated.

<script type="text/javascript">

$(document).ready(function() {
if(window.location.href.toUpperCase().indexOf("NAME%20OF%20LIST/NEWFORM.ASPX")>0 || (window.location.href.toUpperCase().indexOf("NAME%20OF%20LIST/EDITFORM.ASPX?ID")>0)){

//alert("inside function");
var loginName = "";
var userid = _spPageContextInfo.userId;

function GetCurrentUser() {
var requestUri = _spPageContextInfo.webAbsoluteUrl + "/_api/web/getuserbyid(" + userid + ")";

var requestHeaders = { "accept" : "application/json;odata=verbose" };

  url : requestUri,
  contentType : "application/json;odata=verbose",
  headers : requestHeaders,
  success : onSuccess,
  error : onError

function onSuccess(data, request) {
    var loginName = data.d.Title;
    var personEmail=data.d.Email;
    //alert("Hello " + loginName);
    if(personEmail!=="ADD SUPER USER EMAIL ADDRESS")

    //$("input[Title='Change Request Submitter']").val(loginName);

function onError(error) {

  • Hi. This problem has now been resolved in-house. The code is actually working. A stray stylesheet on the site pages we tested was preventing the code from working effectively on those specific pages. It has now been removed and the cog has reappeared as required. Thanks and apologies to anyone who spent any time looking into the issue today.
    – Matt
    Mar 2 at 15:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.