How can I hide main menu items based on user login details

How can I hide items in a main menu for specific users based on their login details?

Hi Makayla,

You need a simple JS code snippet for this which is provided below. This code snippet assumes you have the hamburger menu. If you want this to be applied to every page then add this to the Global JS whereas if you want this applied on one page then add to the screen JS.

Fliplet.User.getCachedSession().then(function(session) {
  var user = _.get(session, 'entries.dataSource.data');

  if (!user) {
    return; // user is not logged in
  }
  
  $('.linked.with-icon.focus-outline').each(function(index, element) {
    //Enter matching menu item name here
    if (
      $(element)
        .text()
        .trim() === 'News'
    ) {
      //Change logged in user property here
      if (user.Admin === 'Yes'){
        $(element).hide()
      }
    }
  });
});

Hope this helps,
Deb