Recurring events – start and end date not set after save

Home Forums Calendar Products Events Calendar PRO Recurring events – start and end date not set after save

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #1193075
    Impact Hub
    Participant

    Hello,

    I’ve finally made it to obtain credentials from our global support team so I am reaching to you through this Premium support.

    Here is my problem

    Thanks in advance!

    #1193704
    Geoff B.
    Member

    Good 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.

    #1194425
    Geoff B.
    Member

    Hey 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 instance
    post_parent post 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.

    #1194459
    Impact Hub
    Participant

    Hello,

    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!

    #1195411
    Geoff B.
    Member

    Hey 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.

    #1195490
    Impact Hub
    Participant

    Hello,

    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.
    #1195820
    Geoff B.
    Member

    Good 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.

    #1196665
    Geoff B.
    Member

    Good 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.

    #1200939
    Impact Hub
    Participant

    Hi there!

    Everything works just fine!

    Thanks for your help!

    It was pleasure to cooperate with you!

    #1200973
    Geoff B.
    Member

    Good 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.

Viewing 10 posts - 1 through 10 (of 10 total)
  • The topic ‘Recurring events – start and end date not set after save’ is closed to new replies.