Skip to content

Instantly share code, notes, and snippets.

@jo-snips
Created March 21, 2012 16:24
Show Gist options
  • Select an option

  • Save jo-snips/2149250 to your computer and use it in GitHub Desktop.

Select an option

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
Copy Markdown
Author

You're welcome! Glad to hear it :)

@jo-snips

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown

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