• I have the latest version of User Role Editor installed. I have installed a plug-in called “The Events Calendar”. I would like to allow only people with contributor level or higher to view and edit the calendar. How do I do that?

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author Vladimir Garagulya

    (@shinephp)

    Send the exact link to the “Events Calendar” plugin.

    Thread Starter amenu

    (@amenu)

    Plugin Author Vladimir Garagulya

    (@shinephp)

    Events menu uses these user capabilities:
    Events (edit_tribe_events)
    Add New (create_tribe_events)
    Tags (manage_categories)
    Event Categories (publish_tribe_events)
    Venues (edit_tribe_venues)
    Organizers (edit_tribe_organizers)
    Import (publish_tribe_events)
    Settings (manage_options)
    Help (manage_options)
    Event Add-Ons (install_plugins)

    Create a role(s) with needed capabilities, so only users with that role(s) will can edit events. You may add such role as a secondary to the contributors, authors, editors, etc…

    Plugin Author Vladimir Garagulya

    (@shinephp)

    I looked at the ‘The Events Calendar’ code. It adds needed capabilities to all WP built-in roles (except subscriber). So they should can edit events by default.
    Look at the caps under custom post types: Venues, Organizers, Events.

    Thread Starter amenu

    (@amenu)

    Hi Vladimir,

    I created a role “contributor2” and assigned to it the capability to edit the events calendar. Visitors and subscribers cannot edit the calendar. However, visitors and subscribers can still view the events calendar when they click on the little “Events” icon at the top left of the window. I want only contributor2 members to be able to view the calendar. Is there a way to restrict viewing the events calendar to contributor2, so that visitors and subscribers cannot see the events in the calendar?
    — Arthur

    Plugin Author Vladimir Garagulya

    (@shinephp)

    Hi Arthur,

    Is that small icon available at front-end? I do not work with “The EC”, so screenshot would be helpful.

    Thread Starter amenu

    (@amenu)

    Hi Vladimir,

    https://we.tl/trWWaD5Dto

    You will see the little icon next to the word “Events”.

    — Arthur

    Plugin Author Vladimir Garagulya

    (@shinephp)

    Hi Arthur,

    Try this code:

    
    add_action('tribe_pre_get_view', 'events_for_members_only');
    
    function events_for_members_only() {
      if (!is_user_logged_in() || !current_user_can('edit_posts')) {
          echo 'You do not have enough permissions to view this page';
      }
    }
    
    add_filter('tribe_get_current_template', 'return_unexisted_template');
    function return_unexisted_template($template) {
      if (!is_user_logged_in() || current_user_can('edit_posts')) {
          $template = 'zzzzz.zzz';
      }
      
      return $template;
    }
    

    Add to functions.php or set as a must-use plugin.

    Thread Starter amenu

    (@amenu)

    Hi Vladimir,

    I copied and pasted the code you suggested at the end of my theme’s functions.php file. When I logged out I got the following error message:

    Parse error: syntax error, unexpected ‘function’ (T_FUNCTION) in /home/sprigme/public_html/wp-content/themes/twentythirteen/functions.php on line 557

    The web site could not be opened.

    I did not know enough to fix the problem so I asked a more knowledgeable person for help and he edited the file to delete the code, and now the website is up and running. I thank you for the suggestion but it did not work.

    — Arthur

    Plugin Author Vladimir Garagulya

    (@shinephp)

    Hi Arthur,

    I tested this code before show it to you.
    This syntax error message may be caused by a fact that code was inserted into not right place – inside another function for example. You may try to setup it as a must use plugin.
    Create file in the text editor, insert ‘<?php’ as a 1st line, insert code below 1st line, save file with .php extension, e.g. the-events-front-end-read-only.php, place int into wp-content/mu-plugins/ folder. It will be executed by WordPress automatically.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘The Events Calendar’ is closed to new replies.