• Resolved Evan

    (@skysarwer)


    Hi there,

    I am working on an event management / booking system with your plugin, which is proving to be very powerful so far.

    I realized that one area that can be improved is with the recurring event system; If a user wants to extend the recurring event to cover more months or days in the calendar, doing so will remove all the old booking data from the system, unless they manually “detach” each event.

    I think this can easily be improved by introducing an option to automatically “detach” old events from the recurring event object.

    While it would be great to have this as a core feature in the plugin, I would be very happy to simply find some directions to hook into the plugin and add the feature in my theme.

    Do you have available :

    • A hook for when an event ends
    • A php function to detach that event from the recurring event object

    ?

    This would be super appreciated and would add A LOT of power to an already fantastic plugin. Thank you so much!

    Warm regards,
    Evan

    • This topic was modified 3 years, 6 months ago by Evan.
    • This topic was modified 3 years, 6 months ago by Evan.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support angelo_nwl

    (@angelo_nwl)

    Hi,

    1, I have tried this filter but you can try em_event_end, you can find this under classes/em-event.php

    2. You can try to use detach() under classes/em-event.php

    Thread Starter Evan

    (@skysarwer)

    Hi Angelo,

    Thank you so much for the reply. I have this code I added based on your suggestions:

    add_filter('em_event_end', 'detach_old_event');
    function detach_old_event($this) {
    	$this->detach();
    }

    Does this seem right to you? Thank you so much!

    Hello Evan,

    Did you test that code, Has it worked?

    Thread Starter Evan

    (@skysarwer)

    Hi Imran, I did test it and it doesn’t work.

    Using $this as the variable breaks the site. I switched it for a more neutral $event parameter, and it causes an error when loading the events on the admin.

    If you take a shot at it please keep us updated ??

    Plugin Support angelo_nwl

    (@angelo_nwl)

    should be something like

    
    add_filter('em_event_end', 'detach_old_event',100,2);
    function detach_old_event($end_date, $EM_Event) {
     //check the event end date then detach
     $EM_Event->detach();
     retun $end_date;
    }
    

    note:
    – the above might not work out of the box but should give you a good start
    – at the moment we are quite limited with regards to custom coding as per the support policy – https://eventsmanagerpro.com/support-policy/

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Hook into event when an event ends to detach event from recurring event object’ is closed to new replies.