Events+ events order

Issue with EVENTS+:
Sometimes events appear in the wrong order on the calendar page, for example an event that starts on 06:30 will appear after an event that starts on 20:30. The time format is 24 and not 12.

This issue doesn't occur everywhere - in most cases everything works perfectly, all the events are in the right order. I have granted support access, please check: 22/05/17 for example. (page slug is /events).

  • James Morris

    Hello amir levy,

    I'm terribly sorry for the extreme delay in response to this thread. Somehow it seems to have slipped through the cracks. :slight_frown:

    In order to help you better with your issue, would you please grant me access to your site and provide me with the link to your events page?

    You can learn how to grant WPMU DEV Support Access at the following link:

    https://premium.wpmudev.org/docs/getting-started/getting-support/#chapter-4

    Please reply back here once you've enabled access so I will be notified.

    Best regards,

    James Morris

  • Ash

    Hello amir levy

    Please go to /wp-content/plugins/events-and-bookings/lib/class_eab_calendar_helper.php line no 88 to 100 and replace

    foreach ($post_info as $ipost) {
    				for ($k = 0; $k < count($ipost['event_starts']); $k++) {
    					$start = strtotime($ipost['event_starts'][$k]);
    					$end = strtotime($ipost['event_ends'][$k]);
    					if ($start < $current_day_end && $end > $current_day_start) {
    						$this->set_event_info(
    							array('start' => $start, 'end'=> $end),
    							array('start' => $current_day_start, 'end'=> $current_day_end),
    							$ipost
    						);
    					}
    				}
    			}

    with

    if( apply_filters( 'eab_event_calendar_display_list_customize', true ) )
    			{
    				foreach ($post_info as $ipost) {
    					for ($k = 0; $k < count($ipost['event_starts']); $k++) {
    						$start = strtotime($ipost['event_starts'][$k]);
    						$end = strtotime($ipost['event_ends'][$k]);
    						if ($start < $current_day_end && $end > $current_day_start) {
    							$this->set_event_info(
    								array('start' => $start, 'end'=> $end),
    								array('start' => $current_day_start, 'end'=> $current_day_end),
    								$ipost
    							);
    						}
    					}
    				}
    			}
    			else
    			{
    				do_action( 'eab_event_calendar_display_list_reorder', $post_info, $this, $current_day_start, $current_day_end );
    			}

    Don't worry about the editing, it will be added in next version.

    Now you have to use the following code:

    add_filter( 'eab_event_calendar_display_list_customize', '__return_false' );
    add_action( 'eab_event_calendar_display_list_reorder', function( $post_info, $obj, $current_day_start, $current_day_end ) {
    	$temp = array();
    	foreach ($post_info as $ipost) {
    		for ($k = 0; $k < count($ipost['event_starts']); $k++) {
    			$start = strtotime($ipost['event_starts'][$k]);
    			$end = strtotime($ipost['event_ends'][$k]);
    			if ($start < $current_day_end && $end > $current_day_start) {
    				$t = $ipost;
    				$t['event_starts'] = array_intersect( array( $t['event_starts'][$k] ), $t['event_starts'] );
    				$t['event_ends'] = array_intersect( array( $t['event_ends'][$k] ), $t['event_ends'] );
    				array_push( $temp, $t );
    			}
    		}
    	}
    
    	usort( $temp, function( $a, $b ) {
    		return $a['event_starts'][0] > $b['event_starts'][0];
    	} );
    
    	foreach( $temp as $t )
    	{
    		$obj->set_event_info(
    			array('start' => strtotime($t['event_starts'][0]), 'end'=> strtotime($t['event_ends'][0])),
    			array('start' => $current_day_start, 'end'=> $current_day_end),
    			$t
    		);
    	}
    }, 99, 4 );

    You can use this code in your theme's functions.php if the theme is not changed. Otherwise mu-plugin is the best option. To create a mu-plugin, go to wp-content/mu-plugins folder. If there is no mu-plugins folder then, create one. Now, inside the mu-plugins folder create file with name anything.php (make sure file extension is .php). Now start with a <?php tag and then put the above code.

    Hope it helps! Please feel free to ask more questions if you have any.

    Have a nice day!

    Cheers,
    Ash

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.