Skip to content

Instantly share code, notes, and snippets.

@jo-snips
Created March 21, 2012 16:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jo-snips/2149250 to your computer and use it in GitHub Desktop.
Save jo-snips/2149250 to your computer and use it in GitHub Desktop.
The Events Calendar: Patch for Private Events
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);
}
@jo-snips
Copy link
Author

Modify getEvents() in /wp-content/plugins/events/lib/the-events-calendar.class.php on line 2348

@trewknowledge
Copy link

So do I add this code to my functions.php file? or in tribe-community-events.class.php file?

@jo-snips
Copy link
Author

You'll need to modify tribe-community-events.class.php and remember the next time you update the plugin, this hack will be wiped! So, you'll need to add it again.

@trewknowledge
Copy link

I came to this site from this WP Support Topic: http://wordpress.org/support/topic/plugin-the-events-calendar-private-events-1

Is this not a patch for The Events Calendar? It appears it is for the Community Events plugin.

@jo-snips
Copy link
Author

Ooops, you're right good catch, I had put the path to the community events class. It's corrected now.

@trewknowledge
Copy link

Thanks! The patch works great!

@jo-snips
Copy link
Author

You're welcome! Glad to hear it :)

@jo-snips
Copy link
Author

No, this patch is for the base The Events Calendar plugin. You need to modify the core /wp-content/plugins/the-events-calendar/lib/the-events-calendar.class.php file on (currently) lines 2478 - 2489.

@jo-snips
Copy link
Author

No, this patch is for the base The Events Calendar plugin and you need to modify the core /wp-content/plugins/the-events-calendar/lib/the-events-calendar.class.php file on (currently) lines 2478 - 2489.

@cayastrife
Copy link

Does anybody have an updated patch for the latest version? I've tried inserting the old code, but it keeps spitting out errors. I'm very desperate to get this to work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment