Recurring event iCal export link doesn't generate recurring calendar event

Home Forums Calendar Products Events Calendar PRO Recurring event iCal export link doesn't generate recurring calendar event

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #1112549
    joshuacboorman
    Participant

    Hi there,

    I’m attempting to generate a downloadable calendar file for either iCal or Google Calendar that will import each event in a series of recurring events. I’ve found the functionality that appears to be designed to do this ( tribe_get_recurrence_ical_link() ), but it doesn’t work as far as I can tell. It generates a working .ics file no problem, but it just contains the first event in the series. The function seems to work by adding child events by their ID, but since (as I understand it) recurring events all share a post ID only one event is getting included in the ics export.

    Am I missing something, or is this feature not working as intended? I’ve attached a screenshot of the recurrence settings for reference. I’ve also tried it with other settings with the same result (recurring Every Week to end in several weeks, for example).

    Thanks much.

    #1112916
    Nico
    Member

    Hi there,

    Thanks for reaching out and sorry to hear about this issue!

    I made a snippet a while back to add a button to export the recurrence series instead of the single events, I guess this is what you are looking for. Paste the snippet below in your theme (or child theme) functions.php file:

    https://gist.github.com/niconerd/3876598a70b521f87cc40ac0e0ec37f0

    Access a recurrent single event details page and let me know if it works for you.

    Best,
    Nico

    #1113018
    joshuacboorman
    Participant

    Thanks for the response Nico,

    I actually already found that snippet when I was hunting for a solution earlier – like I mentioned in my initial post, the tribe_get_recurrence_ical_link() function you’re using in that snippet doesn’t seem to work as intended. I’m using that snippet currently, but it only outputs an ics file of the first event.

    It looks like the tribe_get_recurrence_ical_link() function tries to compile an event series by assembling a list of event post IDs, but since events in a recurring series all share the same ID you only get the first event anyway.

    Much appreciated anyway – any other ideas?

    #1113243
    Nico
    Member

    Hey thanks for following up!

    The snippet is working as expected in my local site – I made a new recurring event with two dates as yours and it works like a charm.

    Can you please follow the steps described in our Testing for conflicts guide? This way we can see if this is a problem in our plugin or a conflict with the theme or other installed plugins. Also are you using latest versions of the plugins?

    Finally could you follow up with the event URL where I can see this in action?

    Best,
    Nico

    #1116194
    joshuacboorman
    Participant

    I’ve followed your guide for testing for conflicts with no change in behaviour. I’m using the latest version of the plugins. Unfortunately I can’t give you a link as it’s a client website on our staging server.

    As far as I can tell, the problem is occurring in this part of the tribe_get_recurrence_ical_link() function:

    $child_events_ids = tribe_get_events( array(
    	'fields'      => 'ids',
    	'post_parent' => $parent_id
    ) );

    In my case $parent_id is always the $event_id at this point, as none of the events have $post->parent set. I’ve dumped all the events via tribe_get_events() and $post->parent is 0 on each of them. $child_events_ids is just an empty array after the above assignment – what’s more, the below also returns an empty array, even though it should at least return an array of existing event IDs:

    tribe_get_events( array(
    	'fields' => 'ids'
    ) );

    As a result the link generated for the iCal export is: http://[link to event]?ical=1&event_ids=5968

    If I add other event ids to that URL by hand it works perfectly, so it’s just that it isn’t finding the recurring event children when it looks for them.

    Any idea why this would be happening?

    #1116555
    Nico
    Member

    Thanks for the detailed follow-up!

    In my case $parent_id is always the $event_id at this point, as none of the events have $post->parent set.

    This sounds very weird, because recurring events do have a parent which is is the main event of the series. Basically this is how events in a series are linked, so if posts that are part of a series don’t have a parent there’s def something going on!

    Are you testing this in the single event page? Can you try adding this snippet in the theme (or child theme) functions.php file?


    function print_event_parent ( ) {

    var_dump( wp_get_post_parent_id( get_the_ID() ) );

    }

    add_action ( 'tribe_events_single_event_before_the_content', 'print_event_parent' );

    Can you give this a try with the main event in the series but also with upcoming and passed instances of the same event? That should dump the ID of the parent event. If there’s some oddness still we can manage to do this in a different way from the snippet.

    Please let me know about it, but I’m mostly sure I’ll need to re-factor the snippet if the parent is being printed as 0!
    Best,
    Nico

    #1116858
    joshuacboorman
    Participant

    Thanks Nico,

    I’ve been testing this in the single events page, yes. I added that snippet and, oddly, initially it was showing a parent ID of 0 on all recurring events as before, but to double-check I created a new test recurring event and that one had its post_parent IDs set correctly. My only guess is the old event was around prior to updating WordPress and the plugin, so maybe the data for the old events got mangled in some way.

    No change in the issue with retrieving the event series via tribe_get_events(), either way – it’s like that function (and get_posts() for that matter, which I also tried) simply can’t see the child events.

    #1116929
    Nico
    Member

    That’s odd indeed Joshua… Do you think it relates to the old event being in the past, and the new one being in the future?

    When the parent ID was present, Did the export series link worked as expected?

    No change in the issue with retrieving the event series via tribe_get_events(), either way – it’s like that function (and get_posts() for that matter, which I also tried) simply can’t see the child events.

    Not sure about the above, I was asking if this was tested in the single event page because the snippet is coded with this purpose. I haven’t tested other implementations of it.

    Have a great weekend,
    Nico

    #1121061
    joshuacboorman
    Participant

    I don’t think so – both events were set to occur in the future.

    No change in behaviour when the parent ID was present. Still exported a single event and ignored the rest of the series.

    I’ve exclusively been testing this in single event pages – that comment is in reference to me tinkering with the tribe_get_events() function your snippet calls to see where things were going wrong.

    #1121645
    Nico
    Member

    Hey Joshua,

    Thanks for the follow-up and patience! I think I discovered why we are not seeing the same thing.

    It’s all about a setting: Recurring event instances (Events > Settings > General). If this option is enabled then the script won’t work as intended, but if it’s unchecked it should work.

    I created a snippet to get the IDs “manually”:

    https://gist.github.com/niconerd/0d9f3ad446e8ab1556a83892ca8113d5

    But if the option is not checked it fails anyway.

    Can you give this a try (I mean disable that option and check if the original snippet works after)? This is definitively a bug we will get sorted but before logging it I just want to make sure my theory is right.

    Thanks a lot and sorry for the hassle here,
    Best,
    Nico

    #1126475
    joshuacboorman
    Participant

    Hi Nico,

    Aha! Brilliant, having that setting unchecked fixed the issue, all looks good now. Thanks very much for your help.

    #1126686
    Nico
    Member

    Glad we could work this out Josh! It was a tricky issue, thanks for the patience while we worked it out 🙂

    I’ll go ahead and close out this thread, but if you need help with anything else please don’t hesitate to create a new one and we will be happy to assist you.

    Best,
    Nico

Viewing 12 posts - 1 through 12 (of 12 total)
  • The topic ‘Recurring event iCal export link doesn't generate recurring calendar event’ is closed to new replies.