Home › Forums › Calendar Products › Events Calendar PRO › Recurring events – start and end date not set after save
- This topic has 10 replies, 3 voices, and was last updated 9 years, 4 months ago by
Impact Hub.
-
AuthorPosts
-
November 16, 2016 at 5:38 am #1193075
Impact Hub
ParticipantHello,
I’ve finally made it to obtain credentials from our global support team so I am reaching to you through this Premium support.
Thanks in advance!
November 16, 2016 at 11:09 pm #1193704Geoff B.
MemberGood evening Bobby and welcome back!
This is quite an interesting question.
Just to set expectations, the scope of our premium support is mostly to get our customers started on the right track and to help them in case of issues.
We unfortunately do not provide complete support for customization.
With that in mind, I would like to run your question by our WPML Dev expert to see if he could shed some light on this.
Hang in there as I do this for you.
Best regards,
Geoff B.
November 18, 2016 at 6:25 am #1194425Geoff B.
MemberHey Bobby,
I did manage to get some feedback from our Dev.
When saving recurring events we do not save in one run but in batches of 10.
This means that if some recurring event creation/update would generate 100 events we save 10 each in 10 background/cron jobs.
Your code needs to do something after we have finalized each recurrence instance data, I would hook into this action:
/**
* Triggers when a recurring event instance is inserted due to the whole series being created or updated.
* This action will not fire if a recurring event instance is broken out of the series (e.g. using the "Edit Single" link).
*
* @param int $post_id The updated recurring event instance post ID.
* @param int $parent_id The updated recurring event instancepost_parentpost ID.
*/
do_action('tribe_events_pro_recurring_event_save_after', $this->post_id, $this->parent_id);Let me know if that helps.
Have a great day!
Geoff B.
November 18, 2016 at 7:44 am #1194459Impact Hub
ParticipantHello,
thanks for this help. I will dig into it during the next few days and I will get back to you with some feedbacks.
For now, this really looks like a solution.
Thanks!
November 21, 2016 at 10:33 am #1195411Geoff B.
MemberHey Bobby,
I was just following-up on this to see how things went.
Let me know when you get a chance.
Have a great day!
Geoff B.
November 21, 2016 at 12:53 pm #1195490Impact Hub
ParticipantHello,
your solution have fixed 90% of my problems! Thanks for this – it was pretty helpful advice and I would never figure it out on my own.
Unfortunately, there is still one strange thing.
Once the event is recurring the save_post hook
add_action('save_post', 'syncWithGoogleCalendar', 1000, 1);
is not fired for the master event (the first occurence) if you only change some of the Events Calendar meta data (recurrence settings, time, price, etc.). So it means that my custom script does not know that the first occurence was somehow changed. Interestingly, it is fired for the children events (next recurences) without problem.If I edit some of my custom built metadata (or change the content, thumbnail image or anything else) save_post is triggered for all events.
One practice example: I create a recurring event – everything works just fine. Then I edit the description of the event (WP content) – everything is just fine. But when I just change the start time and hit Update button the save_post hook is fired for all of the occurence except the first one – the parent post.
Thanks for your support.
-
This reply was modified 9 years, 5 months ago by
Impact Hub.
November 22, 2016 at 8:06 am #1195820Geoff B.
MemberGood morning Bobby,
This is awesome progress!
Let me check that last part for you with our Dev Ninja to see if he has any ideas on this.
Hang in there as I do that for you.
Have a great day!
Geoff B.
November 23, 2016 at 10:59 am #1196665Geoff B.
MemberGood day Bobby,
I followed up on this for you and here are my findings:
You stumbled upon a quite known issue with wp filters and actions that is: infinite loop of save; to avoid that we, as many other devs, hack the action loop to remove/re-add the possible sources and that might break, as in this case, some code downstream. Code is worth thousands words: just use TEC own hook:
/**
* Plugin Name: GSync on save
* Plugin URI: PLUGIN SITE HERE
* Description: PLUGIN DESCRIPTION HERE
* Author: YOUR NAME HERE
* Author URI: YOUR SITE HERE
* Text Domain: save-post
* Domain Path: /languages
* Version: 0.1.0
*
* @package GSync
*/add_action( ‘tribe_events_update_meta’, ‘syncWithGoogleCalendar’, 10, 1 );
add_action( ‘save_post’, ‘syncWithGoogleCalendar’, 1000, 1 );function syncWithGoogleCalendar( $id ) {
$post = get_post( $id );if ( ! tribe_is_recurring_event( $id ) ) {
return;
}$master = $post->post_parent == 0 ? ‘master’ : ‘child’;
// sudo sync
error_log( sprintf( ‘Syncing post [%d] – recurrence %s’, $id, $master ) );
}Let me know if that helps.
Have a great day!
Geoff B.
December 2, 2016 at 9:00 am #1200939Impact Hub
ParticipantHi there!
Everything works just fine!
Thanks for your help!
It was pleasure to cooperate with you!
December 2, 2016 at 10:18 am #1200973Geoff B.
MemberGood afternoon Bobby,
I am super stoked this worked out for you.
Thank you for your great words.You are welcome back in our support forums any time 🙂
For now, I am going to close this thread.
Have a great weekend!
Geoff B.
-
This reply was modified 9 years, 5 months ago by
-
AuthorPosts
- The topic ‘Recurring events – start and end date not set after save’ is closed to new replies.
