Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Garconis/879bb6005f0aa5b8b3183bebd87ce6e5 to your computer and use it in GitHub Desktop.
Save Garconis/879bb6005f0aa5b8b3183bebd87ce6e5 to your computer and use it in GitHub Desktop.
WordPress | Have WP All Import send an email when an import is finished
<?php
// Send an email containing the import results after the import has finished
function fs_email_results( $import_id ) {
global $wpdb;
$table = $wpdb->prefix . 'pmxi_imports';
$data = $wpdb->get_row( 'SELECT * FROM `' . $table . '` WHERE `ID` = "' . $import_id . '"' );
if ( $data ) {
$msg = "Import Report for Import ID " . $import_id . "\r\n\r\n";
$msg .= "Created: " . $data->created . "\r\n";
$msg .= "Updated: " . $data->updated . "\r\n";
$msg .= "Skipped: " . $data->skipped . "\r\n";
$msg .= "Deleted: " . $data->deleted . "\r\n";
wp_mail( '[email protected]', 'Import Report', $msg );
}
}
add_action( 'pmxi_after_xml_import', 'fs_email_results', 10, 1 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment