eventsmanager icon

Prevent duplicate recerrence when using [events_list]

eventsmanager | PRO | 09/02/26 09:36:43 AM UTC | 0 ⭐ | 38582 👁️ | Never ⏰ | []
text |

930 B

|

None

|

0 👍

/

0 👎

<?php
 /*
 * Prevent duplicate recerrence when using [events_list view="grid" scope="future"]
 */
 add_filter( 'em_events_output_events', function( $events, $events_count, $args ) {
 	$unique_events    = array();
	$seen_recurrences = array();
	$today            = current_time( 'Y-m-d' );
 	foreach ( $events as $EM_Event ) {
 		if (
			! empty( $EM_Event->event_type ) &&
			$EM_Event->event_type === 'recurrence' &&
			in_array( $args['scope'] ?? '', array( 'all', 'future' ), true )
		) {
 			$recurrence_id = $EM_Event->post_id;
 			// Skip past recurrence events.
			if ( $EM_Event->event_end_date < $today ) {
				continue;
			}
 			// Skip duplicate recurrence events.
			if ( in_array( $recurrence_id, $seen_recurrences, true ) ) {
				continue;
			}
 			// Mark this recurrence as seen.
			$seen_recurrences[] = $recurrence_id;
		}
 		$unique_events[] = $EM_Event;
	}
 	return $unique_events;
 }, 10, 3 );

Comments

  • roostakbitss icon
    09/11/26 07:24:13 PM UTC
    text |

    0 B

    |

    0 👍

    /

    0 👎

    so i figured out a way to get free digital products from g2a. more specifically steam gift cards, google play gift cards and amazon gift cards. just watch this video if you dont believe me.
     https://www.youtube.com/watch?v=MGSvVHV5Nvk&t=439s
    https://www.youtube.com/watch?v=MGSvVHV5Nvk&t=439s
    https://www.youtube.com/watch?v=MGSvVHV5Nvk&t=439s