How hide calendar menu item

Your software
My Mautic version is:3
My PHP version is: 7.2.33

Your problem
My problem is: I want to be able to hide the calendar. I am setting up a client role and want to hide certain aspects. Role permissions do not cover calendar. And then users can see other users scheduled and upcoming emails. Alternatively, if anyone knows how to solve that issue so a user only sees their own calendar entries.

These errors are showing in the log:

Steps I have tried to fix the problem:

@robm I have been trying to do this, also. I’m unclear what the point of the calendar even is as it seems to show a massive amount of ‘system events’ that are not particularly useful to a marketer. I am currently trying to hide it via css, so far unsuccessfully. If I figure it out, I’ll post it back here.

Hiding unwanted features, and changing labels for others would be huge.

I have also been hunting via CSS, please share if you find the solution as will I.

@robm I have found a way to do it. Not sure if its the recommended way, but it works.

Two-step process:

  1. Create a new .js file in media/js, like ‘myscript.js’

Inside that script put this line:

window.onload = function() {
  document.getElementById("mautic_calendar_index").style.display = "none";
  document.getElementById("mautic_message_index").style.display = "none";
};
  1. Now, open app/bundles/CoreBundle/Views/Default/head.html.php and put this just before the closing tag:

<script src="/media/js/myscript.js"></script>

You are just calling a script from the ‘head’ code that waits until the HTML of the page is loaded and then identifies the HTML element by its ID and sets a css style of display:none;

2 Likes

Champion! It worked.

One edit on instructions. If you name the js script “myscript.js” then use that name in the head.html file script addition. ie replace “headstart” with whatever you named your file.

Great! Thanks for the correction. I just edited the post to be consistent.

I love this little hack, have used it on a number of instances already as the calendar feature is not the best in Mautic unfortunately.

Do you think it is possible to hide the Components menu link for users that do not have permissions to access any of the components module ?
image

Hi @mikew - sorry for the long delay. Have you figured out a way to do this? Off of the top of my head, it seems difficult because you would need to tap into however Mautic authorizes roles and access and then utilize that in the javascript script to hide/show bases on the authorization. I have no idea how to do that! This was more of a ‘broad stroke’ approach that just kills the calendar for everyone.

1 Like

One way is to write a custom code and hide it. Here are the pointers to do so,

  • Listen to the event CoreEvents::BUILD_MENU in your custom plugin
  • And add this $bundles['MauticCalendarBundle']['config']['menu']['main']['items'] = []; to the method. Or $bundles['MauticCalendarBundle']['config']['menu']['main']['items']['mautic.calendar.menu.index']['access'] = '<your-permission-name>';

This will remove the