eventsmanager

Prevent duplicate recerrence when using [events_list]

Sep 2nd, 2026
38,777
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. <?php
  2.  
  3. /*
  4. * Prevent duplicate recerrence when using [events_list view="grid" scope="future"]
  5. */
  6.  
  7. add_filter( 'em_events_output_events', function( $events, $events_count, $args ) {
  8.  
  9. $unique_events = array();
  10. $seen_recurrences = array();
  11. $today = current_time( 'Y-m-d' );
  12.  
  13. foreach ( $events as $EM_Event ) {
  14.  
  15. if (
  16. ! empty( $EM_Event->event_type ) &&
  17. $EM_Event->event_type === 'recurrence' &&
  18. in_array( $args['scope'] ?? '', array( 'all', 'future' ), true )
  19. ) {
  20.  
  21. $recurrence_id = $EM_Event->post_id;
  22.  
  23. // Skip past recurrence events.
  24. if ( $EM_Event->event_end_date < $today ) {
  25. continue;
  26. }
  27.  
  28. // Skip duplicate recurrence events.
  29. if ( in_array( $recurrence_id, $seen_recurrences, true ) ) {
  30. continue;
  31. }
  32.  
  33. // Mark this recurrence as seen.
  34. $seen_recurrences[] = $recurrence_id;
  35. }
  36.  
  37. $unique_events[] = $EM_Event;
  38. }
  39.  
  40. return $unique_events;
  41.  
  42. }, 10, 3 );
Advertisement
Comments
  • roostakbitss
    65 days
    # text 0.34 KB | 0 0
    1. 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.
    2.  
    3. https://www.youtube.com/watch?v=MGSvVHV5Nvk&t=439s
    4. https://www.youtube.com/watch?v=MGSvVHV5Nvk&t=439s
    5. https://www.youtube.com/watch?v=MGSvVHV5Nvk&t=439s
Add Comment
Please, Sign In to add comment