I’m importing events from a public feed as draft events because I don’t necessarily want them all to appear on my calendar. I go in and hand pick which ones to edit and publish. The problem is that the next time the feed is automatically fetched, all events revert back to draft and disappear from my calendar. Is there any way around this? Also, is there a way to not have the descriptions imported and posted? I just want the event’s name, time, and date to appear.
Here is the feed I’m using:
http://api.serviceu.com/rest/events/occurrences?orgKey=5cd4c8dc-8349-44c1-8277-ad7efe0cf7df&format=ical
Thanks!
Brent Peak
Hi Brent,
Also, is there a way to not have the descriptions imported and posted? I just want the event’s name, time, and date to appear.
I think I answered this on this thread, so I’ll leave that question.
To address your other question. Yes, the site uses the feed to indicate the post status (unless you’ve provided a status in the settings). You can also dynamically change the status.
Similar to the above mentioned thread you can change the details parsed from the iCal feed, or immediately update the event immediately after it’s been updated to ensure the desired result. In this case, perhaps the former is best:
function my_set_event_status_from_feed( $ical_parser ){
if( $ical_parser->events_parsed ){
foreach( $ical_parser->events_parsed as $index => $event ){
//Try to find the event by its UID
$uid = !empty( $event['uid'] ) ? $event['uid'] : false;
$found_event = eo_get_event_by_uid( $uid );
if( $found_event ){
//Event has been found, set post status to whatever status it currently has.
$status = get_post_status( $found_event );
$this->events_parsed[$index]['post_status'] = $status;
}
}
}
}
add_action( 'eventorganiser_ical_feed_parsed', 'my_set_event_status_from_feed' );
(See http://codex.wp-event-organiser.com/hook-eventorganiser_ical_feed_parsed.html for details).
Note: This won’t work if you are setting the status in the feed settings. In that case, the status selected there will be used.
Stephen Harris