Is there a function to check whether an event is imported?

Home Forums Calendar Products Event Aggregator Is there a function to check whether an event is imported?

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #1111745
    Ryan Duval
    Participant

    I’m trying to distinguish between imported and ‘native’ events on my site and was just wondering whether there’s a function to help me do this? Like ‘is_imported()’ or something? I am currently comparing the event_website_url() with the network_site_url() since the event_website_url() on imported events will not match the network_site_url(). It works for now, but it’s a bit hackish and I’d feel better with a cleaner way of doing this since my current method could backfire on me down the line.

    Thanks

    #1111754
    George
    Participant

    Hey Ryan,

    Thanks for reaching out!

    I’m sorry to bear this news, but at this time there is no such method for determining if an event was imported from iCal or not.

    There is one other function or approach here that would work. It’s still a bit “hacky”, but much less so than your current solution—I don’t say this to knock your current solution, because it’s in fact really clever and well done. I only mention it being less “hacky” because this should hopefully be appealing as a more long-term solution.

    On to the solution itself—which is essentially just looking for a meta key on the event called “_uid”. So if you have events you can check for this with something like this:


    foreach( $events as $event ) {

    // Get the event post meta.
    // It's possible in numerous ways, this is just an example.
    $event_id = $event->ID;
    $post_meta = get_post_meta( $event_id );

    // Now look for the _uid key.
    if ( isset( $post_meta['_uid'] ) ) {
    // This is has a UID, and so is from iCal importer.
    } else {
    // No UID, thus likely not from iCal importer.
    }
    }

    ☝️ Tinker around with this and let us know if it helps!

    Cheers,
    George

    #1117404
    Support Droid
    Keymaster

    This topic has not been active for quite some time and will now be closed.

    If you still need assistance please simply open a new topic (linking to this one if necessary)
    and one of the team will be only too happy to help.

Viewing 3 posts - 1 through 3 (of 3 total)
  • The topic ‘Is there a function to check whether an event is imported?’ is closed to new replies.