I suggest you ...

Private/Members Only Calendar

I would like the ability to hide the calendar (and subsequently any events, venues and organisers) from logged out users.

I recently came upon a situation when a site owner asked me to hide the calender unless the user was logged in. I know it is possible to make an event private, however, the site owner didn't like this as they though an empty calendar looked depressing and misleading to potential members of the site.

So why not have the ability to hide any plugin content from users and display an alternative (possibly custom) message requesting the user to login?

I have managed this my self, but it took me quite a while to come up with an effective solution. Here it is if your interested:

<?php

//
// Hide events from logged out users
//

add_filter('template_include', 'hide_events_for_logged_out_users', 99);

function hide_events_for_logged_out_users($template ) {
if (tribe_is_event_query() && (!is_user_logged_in() || !current_user_can('read_tribe_event'))) {
dequeue_tec_scripts();
return restricted_access_template();
}

return $template;
}

function dequeue_tec_scripts() {
wp_dequeue_script('tribe-events-calendar');
wp_dequeue_script('tribe-events-calendar-script');
wp_dequeue_script('tribe-events-bootstrap-datepicker');
wp_dequeue_script('tribe-events-admin');
wp_dequeue_script('tribe-events-settings');
wp_dequeue_script('tribe-events-ecp-plugins');
wp_dequeue_script('tribe-events-bar');
wp_dequeue_script('tribe-events-calendar');
wp_dequeue_script('tribe-events-list');
wp_dequeue_script('tribe-events-ajax-day');
wp_dequeue_script('tribe-mini-calendar');
wp_dequeue_script('tribe-events-pro-slimscroll');
wp_dequeue_script('tribe-events-pro-week');
wp_dequeue_script('tribe-events-pro-isotope');
wp_dequeue_script('tribe-events-pro-photo');
wp_dequeue_script('tribe-events-pro-geoloc');
wp_dequeue_script('calendar-widget-admin');
wp_dequeue_script('tribe-meta-box');
wp_dequeue_script('media-upload');
wp_dequeue_script('jquery-ui-core');
wp_dequeue_script('jquery-ui-sortable');
wp_dequeue_script('farbtastic');
wp_dequeue_script('tribe-jquery-ui');
wp_dequeue_script('tribe-jquery-ui');
wp_dequeue_script('tribe-timepicker');
wp_dequeue_script('tribe-fac');
wp_dequeue_script('tribe-events-pro');
}

function restricted_access_template() {
$template = locate_template(array('restricted_access.php'));
if ($template != '') {
return $template;
}
else {
global $wp_query;
$wp_query->set_404();
status_header(404);
return get_template_part(404);
}
}

40 votes
Sign in
Check!
(thinking…)
Reset
or sign in with
  • facebook
  • google
    Password icon
    Signed in as (Sign out)

    We’ll send you updates on this idea

    Brent J shared this idea  ·   ·  Admin →

    10 comments

    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      Signed in as (Sign out)
      Submitting...
      • Anonymous commented  · 

        I need so bad! I make some workaround using Toolset Plugin
        Showing the shortcuts with a Category Named as Private. and Public If logged or not.

        Still can't beat, the event page: "next and previous", there show everything private and public.

      • Tiffany commented  · 

        This is a critical feature to have for an events calendar. I want to be able to show events that anyone can see, but then also have events that are for logged in members only. Please add this!

      • Anonymous commented  · 

        Saw some discussion for private calendar. Would be great to have private events for logged in members without needing to add a patch. For example, set the event to published as private which would then be viewable by members only.

        Perhaps this is already a feature?

      • Joey commented  · 

        Hi there. It would be nice to be able to password protect the events page. Alternatively, perhaps make the events page show up in the admin so we can add WP password functionality to it.

      • Michael Hamilton commented  · 

        Membership sites that have page-blocking functionality are unable to restrict access to the auto-generated calendar page generated by the plugin. This is a security/privacy gap.

        You have published a helpful KB article explaining how to manipulate the functions.php file but this is a cumbersome solution (and subject to accidental overwrite in future plugin updates) that could easily be solved by a simple preference tickbox:

        0 DISABLE AUTO-GENERATED PAGES

        The content of the standard, auto-generated /events page can easily be replicated with a regular WP page and shortcodes. So, a membership site can be secure and get the needed calendar info.

        Let's keep numbnuts like me out of the functions.php file and close a privacy hole that some users could easily overlook.

      • Carl commented  · 

        I'm using WP eMember and with it I can make "event" for logged in member. I would like to do the same with "events".

      • Emily H commented  · 

        Brent, Thanks for writing this. Can you please explain where to place the code you provided?

        Thanks again

      • Edgar commented  · 

        Great idea. I'm working on a site with membership fucntionality (BuddyPress, another connection TEC should work on in my view) and I want to lure in more members by promising them more events for logged in users, i.e. logged in members. If the above solution works it would be great. I will put it on my developers' list to do.

      • Shaun Robinson commented  · 

        There should be the option of setting events as Private, which would hide them from everyone who isn't logged in.

        Alternatively setting a whole category as private would be useful too.

      Feedback and Knowledge Base