Home › Forums › Calendar Products › Event Aggregator › Is there a function to check whether an event is imported?
- This topic has 2 replies, 3 voices, and was last updated 7 years, 11 months ago by Support Droid.
-
AuthorPosts
-
May 6, 2016 at 3:55 pm #1111745Ryan DuvalParticipant
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
May 6, 2016 at 4:22 pm #1111754GeorgeParticipantHey 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,
GeorgeMay 21, 2016 at 9:35 am #1117404Support DroidKeymasterThis 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. -
AuthorPosts
- The topic ‘Is there a function to check whether an event is imported?’ is closed to new replies.