Support

Home Forums Recurring Events Manager Add-on Irregular behaviour for event creation/update hooks on recurring events

Irregular behaviour for event creation/update hooks on recurring events

Posted: June 24, 2014 at 4:48 am


Joshua

June 24, 2014 at 4:48 am

I’m using the action_hook_espresso_insert_event_success action_hook_espresso_update_event_success hooks to fire off an email containing the details of a new/updated event. You can find my code here in this gist.

The behaviour is fine for single events but when creating/updated recurring events the event_id passed to the hook seems to be irregular. Some of the recurrences come through fine with their own event_id whilst others seem to just use the event_id of the first occurance, and there always seems to be at least one blank email suggesting either no event_id or an invalid event_id was passed.

Could anybody with a bit more knowledge of the EE core shed a bit of light on why this may be?

I also seem to be getting an sql error on when creating recurring events which can be seen here. I believe this is more to do with display the events than creating them though.

Version: 3.1.36.5.P


Tony

  • Support Staff

June 24, 2014 at 9:58 am

Hi James,

As the actions could be used by other users in the current form we prefer not to alter the current behaviour, however I do see the issue when updating a recurring series, the $_REQUEST variable (which is passed with the current ‘update_event_success’ hook) does not update with each event_id for a recurring series. I think the best action here would be to add another hook and pass the current $event_id.

If you go to event-espresso\includes\event-management\update_event.php, line 719 you’ll find:

do_action('action_hook_espresso_update_event_success',$_REQUEST);

If right under that you add

do_action('action_hook_espresso_update_event_success_id', $event_id);

Then alter your function to just use that ID directly for updating and also add a check to ensure $event_id is actually set before querying the database (which was the cause of the SQL error)

https://gist.github.com/Pebblo/050897965dbd9a6382cc

I have added a feature request to have the extra hook included within a future version of EE3, it may possibly be included within the next version major version (3.1.37)

Other than throwing the SQL error with your functions, creating the events seemed to email the correct details, is that correct?


Joshua

June 24, 2014 at 10:22 am

Hi Tony, Thanks for the reply.

The problem isn’t just with updates. Where as an recurring event update will currently produce multiple emails of the same event_id, the event creation emails suffer the more irregular behaviour I mentioned above (always one missing, some fine and some duplicates of the first instance).

The correct data for each event is in the database so once I’ve got the hook passing the correct event_id the emails should be fine. I’ll take a closer look at where the event creation hook is fired with regards to recurring events and see if I can handle it with an extra hook or some conditional logic in the action handler.

Thanks again

The support post ‘Irregular behaviour for event creation/update hooks on recurring events’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso