Created
March 23, 2018 16:02
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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