Enabling Private Events

Home Forums Calendar Products Events Calendar PRO Enabling Private Events

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #16980
    Steve
    Member

    Hello All,

    I’m new to the community and wanted to throw something out in case it could help someone else. We have a requirement with our calendars to allow users to post private events (aka require a login to see an event). After initially installing the plugin, I closed my eyes and prayed that setting visibility of the event post to “Private” would give me the functionality I was looking for. It didn’t, so I looked for a solution.

    Since this plugin is so nicely architected, I was able to change one function in the-events-calendar.class.php file, and achieve the result I was looking for. Basically, by default the getEvents function queries only public visibility posts. I added the following logic to allow public and private posts to be queried as long as the current user has the “read_private_tribe_events” capability:

    public function getEvents( $args = ” ) {
    $tribe_ecp = TribeEvents::instance();

    // Determine if user can read private events. If so, pass private events by default, otherwise hide them.
    global $current_user;
    if (user_can( $current_user->ID, ‘read_private_tribe_events’ ))
    {
    $defaults = array(
    ‘posts_per_page’ => tribe_get_option( ‘postsPerPage’, 10 ),
    ‘post_type’ => TribeEvents::POSTTYPE,
    ‘orderby’ => ‘event_date’,
    ‘order’ => ‘ASC’,
    ‘post_status’ => array( ‘publish’, ‘private’ )
    );
    }else{
    $defaults = array(
    ‘posts_per_page’ => tribe_get_option( ‘postsPerPage’, 10 ),
    ‘post_type’ => TribeEvents::POSTTYPE,
    ‘orderby’ => ‘event_date’,
    ‘order’ => ‘ASC’
    );
    }

    $args = wp_parse_args( $args, $defaults);
    return TribeEventsQuery::getEvents($args);
    }

    I’ve done only a bit of testing so far, and definitely haven’t covered every use case out there, but I thought I’d throw this out in case someone can see a big problem with this or has anything to add.

    I really don’t like modifying the core library to support this, but until this functionality is supported natively, this is the best I’ve got so far.

    -Steve

    #16981
    Steve
    Member

    This is on 2.0.4 by the way.

    #16992
    Jonah
    Participant

    Hi Steve,

    I’m running 2.0.4 and just tested the default functionality of setting an event post as private and then logging out to see if it displayed on my site and it didn’t. So it appears to be working normally for me. I wonder if you have some conflict with another plugin or your theme? Have you tried disabling all other plugins and/or switching to the Twenty Eleven theme to rule out conflicts?

    #16996
    Steve
    Member

    Hi Jonah,

    Thanks for responding and taking a look at this. I see the same behavior as well with the stock plug-in. The behavior I was looking for, though, was to not only hide private events when a user is not authenticated, but to also show those private events when a user with the appropriate capability is authenticated (by default the plug-in sets the Administrator role to have that right).

    On my site, I’ve also given that capability to Editor, Author, Contributor and Subscriber as well so that anyone who is logged in can see the private event.

    Are you seeing private events display (like on the /events page and in the widgets) when you are logged in as an admin with the stock plug-in?

    Thanks!

    #17031
    Jonah
    Participant

    Hey Steve, you’re right I don’t see private events when logged in as an admin and your modification works! I’m going to file a ticket for this and we’ll get it cleared up in a future version. Many thanks for your contribution!

    #17039
    Steve
    Member

    Great. Happy to help!

    #17053
    Rob
    Member

    Thanks for the assistance, Steve. Let us know if we can do anything else for you as you keep using the plugin.

    #17226
    Pack
    Member

    I am using Steve’s work around as well, and it works.

    I would like to know if iris possible to have a private RSS feed for all events, including private events?

    In our orginization we have some events on the calendar that are private to a few users. It would be nice to be able import an rss feed into a Google, Outlook, ipad, etc calendar so each user would have them on their own calendar app.

    #17245
    Rob
    Member

    Hey Pack. Thanks for the note. That’d probably take some work; as it stands now, the RSS feeds are pretty bare bones and don’t include all the event-specific details (though that’s changing for 2.1). I like your request of having a private option and will run it by the team. I’d also suggest adding it to our “Feature Requests” thread (https://theeventscalendar.com/support/forums/topic/events-calendar-pro-feature-requests/), since we use that to gauge what the community wants to see and how we prioritize our work accordingly.

    Sorry I couldn’t offer up more in the short-term. If you’ve got any other questions, just ask.

    #976410
    Support Droid
    Keymaster

    This topic has not been active for quite some time and will now be closed.

    If you still need assistance please simply open a new topic (linking to this one if necessary)
    and one of the team will be only too happy to help.

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