WP All Import
With WP All Import modules in Make, you can watch for new imports and exports.
To use the WP All Import modules, you must have a WP All Import account. You can create an account at wpallimport.com. You must also have a WordPress account with WP All Import and WP All Export plugins.
Set Up WP All Import Webhooks
Log in to your Make account, add one of the WP All Import
instant
modules to your scenario, and click Create a webhook.Optional: Enter a name for the webhook in the Webhook name field.
Click Save > Copy address to clipboard.
Log in to your WordPress account.
Depending on the
instant
module you chose in Step 1, click on either the All Import or All Export plugin > Settings.Depending on the plugin you are using, paste the relevant function in the Function Editor field.
All Import
<?php
function after_import($import_id, $import)
{
global $wpdb;
$table = $wpdb->prefix . "pmxi_imports";
// Retrieve the import data from the database
$import_data = $wpdb->get_row($wpdb->prepare("SELECT * FROM `$table` WHERE `id` = %d", $import_id), ARRAY_A);
// Check if the import data was found
if ($import_data) {
// Check if the 'options' field is set and unserialize it
if (isset($import_data['options'])) {
$import_data['options'] = unserialize($import_data['options']);
}
}
// Define the HTTP request arguments
$args = array(
'timeout' => 5,
'redirection' => 5,
'httpversion' => '1.0',
'blocking' => true,
'headers' => array(),
'cookies' => array(),
'body' => $import_data,
);
// Sends import data to the webhook URL specified.
wp_remote_post("https://hook.make.com/<webhook_id>", $args);
}
add_action('pmxi_after_xml_import', 'after_import', 10, 2);
?>
All Export
<?php
function after_export($export_id, $export)
{
// Check whether "Secure Mode" is enabled in All Export -> Settings
$is_secure_export = PMXE_Plugin::getInstance()->getOption('secure');
if (!$is_secure_export) {
$filepath = get_attached_file($export->attch_id);
} else {
$filepath = wp_all_export_get_absolute_path($export->options['filepath']);
}
$wp_uploads = wp_upload_dir();
$fileurl = str_replace($wp_uploads['basedir'], $wp_uploads['baseurl'], $filepath);
$body = (array) $export;
// Add export file details to the body if the file exists
if (file_exists($filepath))
{
$body['export_file_url'] = $fileurl;
$body['file_name'] = basename($filepath);
$body['file_type'] = wp_all_export_get_export_format($export->options);
$body['export_trigger_type'] = empty($_GET['export_key']) ? 'manual' : 'cron';
}
// Define the HTTP request arguments
$args = array(
'method'=> 'POST',
'body'=> $body,
'timeout' => 5,
'redirection' => 5,
'httpversion' => '1.0',
'blocking'=> true,
'headers'=> array(),
'cookies'=> array(),
);
// Sends export data to the webhook URL specified
wp_remote_post("https://hook.make.com/<webhook_id>", $args);
}
add_action('pmxe_after_export', 'after_export', 10, 2);
?>
Locate the
wp_remote_post("https://hook.make.com/<webhook_id>", $args);
line in the function you pasted and replacehttps://hook.make.com/<webhook_id>
with the address copied in Step 3.Click Save Functions.
WP All Import will now send data to Make through the webhook when the selected event occurs.
Build WP All Import Scenarios
You can perform the following actions with WP All Import modules:
Watch New Import
Watch New Export