These bigger plugins are often “too cool” to use post_meta/post_custom – thats why you were unable to retrieve the data via the normal plugin way of storing additional info. The dev documentation for ai1ec in bleak, I couldn’t find any functions to simplify the task you were after (though they do exist in the source code if browsed long enough).
The table you’re after is wp_ai1ec_events
(plural. not wp_ai1ec_event
).
Using a tool like phpmyadmin is a great way to build your queries before hand, then make the work in your php code.
I was able to retrieve the end
date information with the following:
add_action('init','myplugin_get_alic_enddate');
function myplugin_get_alic_enddate() {
global $wpdb;
$HitID = 537; // wtv
$query = "SELECT end FROM `{$wpdb->prefix}ai1ec_events` WHERE `post_id` = {$HitID}";
$event = $wpdb->get_row($query);
//echo $event->end;
//echo date(get_option('date_format'),$event->end);
}
This does nothing with events that are all day events or ones with no end date set (obviously).
UPDATE
To reflect the code posted by OP in another answer
add_filter('relevanssi_hits_filter', 'rlv_remove_expired');
function rlv_remove_expired($hits) {
global $wpdb;
$non_expired = array();
$now = time();
foreach ($hits[0] as $hit) {
$HitID = $hit->ID;
$Result_PostType = get_post_type($HitID);
if( $Result_PostType == 'ai1ec_event' ){
echo "<pre>Made it to: if(Result_PostType=='ai1ec_event')</pre>";
$query = "SELECT end FROM {$wpdb->prefix}ai1ec_events WHERE post_id = {$HitID}";
$row = $wpdb->get_row($query);
if($wpdb->last_error !== '') {
echo "<pre> MYSQL ERROR:\n";
$wpdb->print_error();
echo "</pre>";
}
$end_date = $row->end;
echo "<pre>In Function.\n End Date: ".$end_date."\n HitID: ".$HitID."</pre>";
if($end_date >= $now)
$non_expired[] = $hit;
} else {
$end_date = 0;
$non_expired[] = $hit;
}
echo "<pre>Hit ID: ".$HitID."\n End Date: ".$end_date."\n Now: ".$now."\n Post Type: ".$Result_PostType."</pre>";
} // end foreach
$hits[0] = $non_expired;
return $hits;
}