Importing events as drafts

This topic contains 1 reply, has 2 voices, and was last updated by  Stephen Harris 10 years, 2 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #12312

    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
    #12367

    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
Viewing 2 posts - 1 through 2 (of 2 total)
To enable me to focus on Pro customers, only users who have a valid license for the Pro add-on may post new topics or replies in this forum. If you have a valid license, please log-in or register an account using the e-mail address you purchased the license with. If you don't you can purchase one here. Or there's always the WordPress repository forum.