We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 10405
    • 288 Posts
    I've set up myCalendar on 2.6.5 and it seems to work fine except for one very glaring problem - the default behavior seems to be for *anyone* to be able to add an event. Clearly I don't want the general public doing this so is there a way of making it so only admin can add events, i.e be logged in to the back end and then click a date to add an event on a separate browser tab? Only admin should be able to add events. Very surprised this isn't default behavior. Anyone have any ideas? Thanks.

    I would also point out that I've tried the following options:

    &allowGuestEdit=`0` 
        &readOnly=`1`
    


    But this also stops admin from being able to add events! [ed. note: galahad5 last edited this post 5 years, 1 month ago.]
      • 3749
      • 24,544 Posts
      The easiest method is a simple utility snippet:

      Put this tag above the MyCalendar tag on the calendar page

      [[!AdminOnly]]


      Create this snippet:

      <?php
      /* AdminOnly snippet */
      
      if (! $modx->user->isMember('Administrator')) {
          return "Sorry, you're not authorized to see this page";
      }
      
      return '';


      Only members of the Administrator group will see the page. Others will see the "Sorry" message.
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 46886
        • 1,154 Posts
        If you want the general public to still be able to see the calendar I believe contexts can help you. You could make a context, give the user group and admins fuller access while limiting anonymous group to read only.

        I haven't tested this though.
          • 10405
          • 288 Posts
          Quote from: BobRay at Feb 27, 2019, 06:03 PM
          The easiest method is a simple utility snippet:

          Put this tag above the MyCalendar tag on the calendar page

          [[!AdminOnly]]


          Create this snippet:

          <!--?php
          /* AdminOnly snippet */
          
          if (! $modx--->user->isMember('Administrator')) {
              return "Sorry, you're not authorized to see this page";
          }
          
          return '';


          Only members of the Administrator group will see the page. Others will see the "Sorry" message.

          Thanks, the problem though is that UI need the general public to see the calendar (and browse through it), I just don't want them being able to add events...?
            • 10405
            • 288 Posts
            I've decided to use mxCalendar instead- works differently but should do the job. Thanks for the replies, both smiley