Issue with eo_insert_event();

This topic contains 3 replies, has 2 voices, and was last updated by  Stephen Harris 9 years ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #21842

    When I call eo_insert_event() and the dates are different (so I’m adding a 3 day event that does not repeat), only the first day of the event is displayed on the calendar page. Not all 3 days.

    But when I edit it and re-save it without changing anything, it appears correctly in the calendar.

    What am I missing? I am using the sample from http://codex.wp-event-organiser.com/function-eo_insert_event.html

      $new_event = array();
      $new_event['schedule'] = 'once';
      $new_event['frequency'] = 1;
      $new_event['start'] = new DateTime( $event_start, eo_get_blog_timezone() );
      $new_event['end'] = new DateTime( $event_end, eo_get_blog_timezone() );
      $new_event['all_day'] = $event_allday;
    
      $post_id = eo_insert_event( $new_post, $new_event );
    
    Dave Navarro
    #21846

    What values are you using for $event_start and $event_end. The following created an all-day, 3-day event from the 11th March through to the 13th:

      $event_start = '2016-03-11 00:00';
      $event_end = '2016-03-13 23:59';
    
      $new_event = array();
      $new_event['schedule'] = 'once';
      $new_event['frequency'] = 1;
      $new_event['start'] = new DateTime( $event_start, eo_get_blog_timezone() );
      $new_event['end'] = new DateTime( $event_end, eo_get_blog_timezone() );
      $new_event['all_day'] = true;
    
      $post_id = eo_insert_event( array( 'post_title' => 'Test event' ), $new_event );
    
    Stephen Harris
    #21847

    I am pulling it from a form:

      $event_start  = $_POST['item_meta'][346];
      $event_end    = $_POST['item_meta'][348];
      if ( $event_allday ) {
        $event_start .= ' 00:00:00';
        $event_end   .= ' 00:00:00';
      } else {
        $event_start .= ' ' . $_POST['item_meta'][349];
        $event_end   .= ' ' . $_POST['item_meta'][350];
      }    
    

    I’m guessing that the end time should not match the start time… That’s the only difference I see between your code and mine.

    Dave Navarro
    #21861

    The time per-se doesn’t matter, though it should be 23:59 for all-day events as otherwise the event will be one-day shorter than intended.

    I’m more interested in the value of $event_start and $event_end: when that script runs what is an example actual vale are they given (it will oibviously depend on user input).

    Stephen Harris
Viewing 4 posts - 1 through 4 (of 4 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.