Skip to content

Instantly share code, notes, and snippets.

@webtoffee-git
Last active June 28, 2021 03:44
Show Gist options
  • Save webtoffee-git/5071e3740c0f502ccb5e8d346358b929 to your computer and use it in GitHub Desktop.
Save webtoffee-git/5071e3740c0f502ccb5e8d346358b929 to your computer and use it in GitHub Desktop.
Send import log to mail after successful cron import- Import and Export Suite for WooCommerce by WebToffee
<?php
add_action('wt_ier_scheduled_action_finished', 'wt_scheduled_action_finished', 10,1);
function wt_scheduled_action_finished($out){
ini_set('max_execution_time', -1);
ini_set('memory_limit', -1);
$wt_log_path = WP_CONTENT_DIR . '/webtoffee_iew_log'; // wp content path - fixed WP violation
$files = glob("$wt_log_path/*.*");
$files = array_combine($files, array_map('filectime', $files));
arsort($files);
$destination = key($files);
$email = 'user@mail.com';//Input your email ID
$object= 'Products imported successfully!';//Specify the subject for email
$message = 'OK. Automatic import performed SUCCESSFULLY. : ' .date('l d/m/Y H:i:s', time() ). '';//Enter the message
$mail_attachment = array($destination);
$headers = '';
wp_mail( $email, $object, $message,$headers,$mail_attachment );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment