1

I want to hide the side navigation from only certain users but we have been specifallly instructed to not mess with the master page. we are only allowed to use CSS or Javascript

  • Publishing feature enables on site or not? – Samir Khimani Feb 16 '17 at 3:39
  • do you want to hide Navigation from users based on permission level or any other criteria? – Ankitkumar Malde Feb 16 '17 at 4:31
  • No need for script if you put the CSS <style> in Content Editor WebPart and use the WebPart-properties Target Audience setting to only include that WebPart for ... a targeted audience – Danny '365CSI' Engelman Feb 16 '17 at 11:28
1

You create a separate Java script file to write the logic and give reference this java script file in master page. or else you can using existing referred javascript file

    var SideMenu = {

    Hide: function (groupname) {

           $.ajax({
            url: _spPageContextInfo.webAbsoluteUrl+"/_api/Web/currentUser/groups?$filter=Title eq '"+groupname+"'",
            method: "GET",
            headers: { "Accept": "application/json; odata=verbose" },
            success: function (data) {
                if(data.d.results.length>=1){
                  $("#sideNavBox").hide();
                }
            },
            error: function (data) {
                console.log(data);
            }
        });
    }  
}

    $(document).ready(function () {
        SideMenu.Hide("GroupName1");
    });

Here GroupName1 you can assign your group name for which you want to hide side menu.

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.