Group Visibility of Items

PHOTO EMBED

Sat Jan 08 2022 03:58:13 GMT+0000 (UTC)

Saved by @rebukt #javascript

/*--- hide left side items ---*/
.subscriber li.menu-pipeline,
.subscriber li.menu-mdf,
.subscriber li.menu-prospect {display: none; }
 
 
 
// JS to show left nav items
jQuery(document).ready(function ($) {
 
 
  var isLoggedIn = !!$(".logged-in").length;
 
  var pipelineItem = "li.menu-pipeline";
  var mdfItem = "li.menu-mdf";
  var prospectPagesItem = "li.menu-prospect";
 
  var eliteCanSeePages = !!(isLoggedIn && abUser.group_id.indexOf("31") > -1);
  var premierCanSeePages = !!(isLoggedIn && abUser.group_id.indexOf("32") > -1);
 
  function showPipeline() {
    return $(pipelineItem).show();
  }
 
  function showMdf() {
    return $(mdfItem).show();
  }
 
  function showProspectPages() {
    return $(prospectPagesItem).show();
  }
 
  function scenarioDriver() {
    for (scenario of scenarios) {
      if (scenario.page && scenario.condition) {
        scenario.outcome();
        break;
      }
    }
  }
 
  var scenarios = [
    {
      condition: eliteCanSeePages || premierCanSeePages,
      page: true,
      debugger: [
        "Logic: if user is in group id 31 or 32, show pipeline mdf and prospect pages",
      ],
      outcome: function () {
        showPipeline();
        showMdf();
        showProspectPages();
      },
    },
  ];
 
  scenarioDriver();
}); // end ready function
content_copyCOPY

Request: Hide the MDF, Pipeline and Prospect Page Items on the left nav from users that are not members of group 31 or 32. In other words, members of group 31 and 32 should continue to see the above items. This request is two parts: (1) Implement CSS to hide the menu items and (2) Implement JS to only show those items to the users that should see it.