ACF with iCal feed

This topic contains 8 replies, has 2 voices, and was last updated by  Stephen Muffatti 4 years, 5 months ago.

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #36379

    Hey there, I’m trying to use ACF to create a custom field on events created through an ical feed. The issue I’m having is that sometimes, usually every other ical fetch, it removes the ACF fields and the associated data from the events. If I hit the “update” button on the event it adds the ACF fields back in but lacks the data.

    Is there a way to prevent this from happening? Is there a hook I could use for the creation of the event with the iCal feed to add the ACF field then so it doesn’t get removed?

    Stephen Muffatti
    #36399

    It seems after more investigation that the iCal fetch is getting the same events but trashing the old ones before inserting the new ones. I guess this means the UID is different?

    Stephen Muffatti
    #36485

    HI Stephen,

    Yes, if the UUIDs are different then it deletes the event and creates a new one.

    Stephen Harris
    #36510

    Hey,

    Thanks for taking the time to respond to my post. I have a couple of follow up questions:

    1. Could tell me where I can see the function that checks the UUIDs to
      see if they are the same or not?

    2. In your experience, have you ever run into an iCal feed that updated
      the UUIDs for each item everytime it was fetch? What could the
      purpose of this be?

    Again, thank you for your hard work and the time you take to respond to these forums.

    Stephen Muffatti
    #36520

    1) That logic is at line 414 of event-organiser-ical-sync/ical-functions.php. It uses eo_get_event_by_uid() to attempt to find an event with that UUID.

    2) Only because the feed hadn’t been implemented properly. The iCal specification offers guidance on generating UUIDs which involves using the current time:

    A good method to assure uniqueness is to put the
    domain name or a domain literal IP address of the host on which the
    identifier was created on the right hand side of the “@”, and on the
    left hand side, put a combination of the current calendar date and
    time of day (i.e., formatted in as a DATE-TIME value) along with some
    other currently unique (perhaps sequential) identifier available on
    the system (for example, a process id number). Using a date/time
    value on the left hand side and a domain name or domain literal on
    the right hand side makes it possible to guarantee uniqueness since
    no two hosts should be using the same domain name or IP address at
    the same time.

    What’s not made explicitly clear is that that should be done once and persisted with the event. If each time the feed is read each event is given a new a UID then its impossible to match events with previous imports.

    Stephen Harris
    #36546

    Alright, so I was able to confirm that once the events are imported that they are in fact getting new UIDs. However, the company supplying the feed insists it’s a problem on my end. How can I confirm that the UIDs are being changed on their end when they refresh their feed and it’s not an issue on my end?

    A side note – I’m having trouble with this plugin on a separate site in which it will not fetch a feed at all and instead gives a 403 forbidden code for a feed that works everywhere else. I’m sort of at a loss for why that’s happening.

    Apologies for my questions, I feel like I must be missing something that’s causing my recent struggles, and thank you again for your time.

    Stephen Muffatti
    #36557

    Hey, as an update:

    I verified that the UIDs were being changed before the plugin using an iCal validator to check the feeds.

    I know it would be bad practice but I’m wondering if there’s a way to switch how the plugin checks for matching UIDs and maybe set it to check Name and Date or something? I’m just trying to think of possible workarounds.

    Stephen Muffatti
    #36570

    Not without editing the plug-in’s code. You replace the call to eo_get_event_by_uid() with something like:

    $found_event = eo_get_events( array(
            'showpastevents' => true,
            'group_events_by' => 'series',
            'no_found_rows' => true,
            'update_post_term_cache' => false,
            'update_meta_term_cache' => false,
            'post_status' => 'any',
            'numberposts' => 1,
            'post_name__in' => [sanitize_title_with_dashes($event_post->post_title)]    
     ));
    

    I’ve not tested, this, and its actually looking up the post title by the slug, so it’s having to generate a slug from the title (which might not match the actual slug).

    So it may require some tweaking.

    Stephen Harris
    #36596

    Thank you for this. I’m going to try and implement this in the next couple of days and I will report back .

    Stephen Muffatti
Viewing 9 posts - 1 through 9 (of 9 total)
To enable me to focus on Pro customers, only users who have a valid license for the Pro add-on may post new topics or replies in this forum. If you have a valid license, please log-in or register an account using the e-mail address you purchased the license with. If you don't you can purchase one here. Or there's always the WordPress repository forum.