Okay I think I have a solution:
WP All Import has it’s own actions which you can hook functions to. By using this you can schedule cron events. (See https://www.wpallimport.com/documentation/advanced/action-reference/).
So I’m experimenting by putting this in my functions.php:
add_action('pmxi_saved_post', 'post_saved', 10, 1);
function post_saved($id) {
$expiration_date = get_post_meta($id, 'expiration-date', true);
if ($expiration_date) {
$opts = array();
$opts['expireType'] = 'delete';
$opts['id'] = $id;
echo "Setting expiration date for post " . $id . " to the timestamp " . $expiration_date;
_scheduleExpiratorEvent( $id, $expiration_date, $opts );
} else {
echo "No expiration date set for post " . $id . ". Exiting";
}
}
The code above fetches the ID of the current post and uses that to get the expiration date.
Provided the post has an expiration date the system will call _scheduleExpiratorEvent which is a function from WP Post Expirator. This in turn with both set the meta and hook to WP’s own cron scheduler, which should then schedule the event.
You’ll notice I’m echoing out some messages – these will appear on your import history logs at the top of each import if things are set up correctly.
You could also modify the code above to fetch the expire type meta field and pass it along as an option, if you want to select how the post is expired.
I’ve only done a quick test on this but it seems to work. By the way you can find out if cron jobs have been set with a neat little plugin called WP Crontrol https://en-gb.www.ads-software.com/plugins/wp-crontrol/ I’d recommend it for checking if your cron events have been setup. One tip though cron events will be under tools > cron events and schedules under settings > cron schedules. I found that a little confusing!